Make indistinguishable results in perf.js the same score.

Former-commit-id: 550c42ba8d07bde5fe1cf57d5bd27df7bc42dd12
This commit is contained in:
John-David Dalton
2012-05-20 04:43:43 -04:00
parent 7b44ef1664
commit 8e2d972281

View File

@@ -28,7 +28,7 @@
/** Used to score Lo-Dash and Underscore performance */ /** Used to score Lo-Dash and Underscore performance */
var score = { 'lodash': 0, 'underscore': 0 }; var score = { 'lodash': 0, 'underscore': 0 };
/** Use a queue benchmark suites */ /** Used to queue benchmark suites */
var suites = []; var suites = [];
/** Add `console.log()` support for Narwhal and RingoJS */ /** Add `console.log()` support for Narwhal and RingoJS */
@@ -69,17 +69,21 @@
console.log(event.target.toString()); console.log(event.target.toString());
}, },
'onComplete': function() { 'onComplete': function() {
var fastest = this.filter('fastest').pluck('name'); var fastest = this.filter('fastest').pluck('name'),
lodashHz = Math.floor(1 / (this[0].stats.mean + this[0].stats.moe)),
underscoreHz = Math.floor(1 / (this[1].stats.mean + this[1].stats.moe));
if (fastest.length > 1) { if (fastest.length > 1) {
console.log('It\'s too close to call.'); console.log('It\'s too close to call.');
lodashHz = underscoreHz = Math.min(lodashHz, underscoreHz);
} else { } else {
console.log(fastest + ' is the fastest.'); console.log(fastest + ' is the fastest.');
} }
// add score adjusting for maring of error // add score adjusted for margin of error
score.lodash += Math.floor(1 / (this[0].stats.mean + this[0].stats.moe)); score.lodash += lodashHz;
score.underscore += Math.floor(1 / (this[1].stats.mean + this[1].stats.moe)); score.underscore += underscoreHz;
// remove from current suite from queue // remove current suite from queue
suites.shift(); suites.shift();
if (suites.length) { if (suites.length) {