summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Early <alexander.early@gmail.com>2015-05-22 00:34:00 -0700
committerAlexander Early <alexander.early@gmail.com>2015-05-22 00:34:00 -0700
commita44d11ca95304dca673e6487050e630c2b2d87ee (patch)
tree642253c6b37c5271f13c38fe690d78e24bec09f1
parenteeb33e687ba6e87f89f0452005571499859c6056 (diff)
downloadasync-a44d11ca95304dca673e6487050e630c2b2d87ee.tar.gz
dezalgo'd benchmarks, use toPrecision in reporting
-rwxr-xr-xperf/benchmark.js10
-rw-r--r--perf/suites.js20
2 files changed, 16 insertions, 14 deletions
diff --git a/perf/benchmark.js b/perf/benchmark.js
index 6ae3d04..da59216 100755
--- a/perf/benchmark.js
+++ b/perf/benchmark.js
@@ -55,11 +55,11 @@ async.eachSeries(versionNames, cloneVersion, function (err) {
.map(createSuite);
async.eachSeries(suites, runSuite, function () {
- var totalTime0 = Math.round(totalTime[version0]);
- var totalTime1 = Math.round(totalTime[version1]);
+ var totalTime0 = +totalTime[version0].toPrecision(3);
+ var totalTime1 = +totalTime[version1].toPrecision(3);
- var wins0 = Math.round(wins[version0]);
- var wins1 = Math.round(wins[version1]);
+ var wins0 = wins[version0];
+ var wins1 = wins[version1];
if ( Math.abs((totalTime0 / totalTime1) - 1) < 0.01) {
// if < 1% difference, we're likely within the margins of error
@@ -139,7 +139,7 @@ function createSuite(suiteConfig) {
return suite.on('cycle', function(event) {
var mean = event.target.stats.mean * 1000;
- console.log(event.target + ", " + mean.toFixed(1) + "ms per sample");
+ console.log(event.target + ", " + (+mean.toPrecision(2)) + "ms per run");
var version = event.target.options.versionName;
totalTime[version] += mean;
})
diff --git a/perf/suites.js b/perf/suites.js
index 6b00b25..9a36db5 100644
--- a/perf/suites.js
+++ b/perf/suites.js
@@ -7,7 +7,7 @@ module.exports = [
// args lists are passed to the setup function
args: [[10], [300], [10000]],
setup: function(count) {
- tasks = Array(count);
+ tasks = _.range(count);
},
fn: function (async, done) {
async.each(tasks, function (num, cb) {
@@ -19,7 +19,7 @@ module.exports = [
name: "eachSeries",
args: [[10], [300], [10000]],
setup: function(count) {
- tasks = Array(count);
+ tasks = _.range(count);
},
fn: function (async, done) {
async.eachSeries(tasks, function (num, cb) {
@@ -31,7 +31,7 @@ module.exports = [
name: "eachLimit",
args: [[10], [300], [10000]],
setup: function(count) {
- tasks = Array(count);
+ tasks = _.range(count);
},
fn: function (async, done) {
async.eachLimit(tasks, 4, function (num, cb) {
@@ -44,10 +44,10 @@ module.exports = [
// args lists are passed to the setup function
args: [[10], [300], [10000]],
setup: function(count) {
- tasks = Array(count);
+ tasks = _.range(count);
},
fn: function (async, done) {
- async.map(Array(10), function (num, cb) {
+ async.map(tasks, function (num, cb) {
async.setImmediate(cb);
}, done);
}
@@ -56,7 +56,7 @@ module.exports = [
name: "mapSeries",
args: [[10], [300], [10000]],
setup: function(count) {
- tasks = Array(count);
+ tasks = _.range(count);
},
fn: function (async, done) {
async.mapSeries(tasks, function (num, cb) {
@@ -68,7 +68,7 @@ module.exports = [
name: "mapLimit",
args: [[10], [300], [10000]],
setup: function(count) {
- tasks = Array(count);
+ tasks = _.range(count);
},
fn: function (async, done) {
async.mapLimit(tasks, 4, function (num, cb) {
@@ -118,7 +118,9 @@ module.exports = [
args: [[10], [100], [1000]],
setup: function (count) {
tasks = _.range(count).map(function () {
- return function (cb) { cb(); };
+ return function (cb) {
+ setImmediate(cb);
+ };
});
},
fn: function (async, done) {
@@ -130,7 +132,7 @@ module.exports = [
args: [[10], [100], [1000]],
setup: function (count) {
tasks = _.range(count).map(function () {
- return function (cb) { cb(); };
+ return function (cb) { setImmediate(cb); };
});
},
fn: function (async, done) {