Skip to content

Commit

Permalink
docs(perf): add RAEDME.md [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
suguru03 committed May 6, 2016
1 parent 57662c3 commit 97e44f4
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 3 deletions.
63 changes: 63 additions & 0 deletions perf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# benchmark

The benchmark tool is using `benchmark.js` and `func-comparator`.

## How to execute

```bash
// execute all cases
$ node ./

// specify benchmark tool
$ node ./ -b benchmark // ['benchmark', 'func-comparator']
$ node ./ -b bench
$ node ./ --benchmark func

// specify function name
$ node ./ --target each // all `each` tasks
$ node ./ --target each:array // only `each:array` task

// specify times (only func-comparator)
$ node ./ -t 10
$ node ./ --times 10
```

## Sample

```bash
$ node ./ --target each

======================================
[async], v2.0.0-rc.4
[neo_async], v2.0.0_pre
======================================
[each:array] Comparating...
--------------------------------------
[benchmark] Executing...
[1] "neo_async" 7.30μs[1.00][1.00]
[2] "async" 22.0μs[0.332][3.01]
--------------------------------------
[func-comparator] Executing...
[1] "neo_async" 80.4μs[1.00][1.00]
[2] "async" 185μs[0.435][2.30]
======================================
[each:object] Comparating...
--------------------------------------
[benchmark] Executing...
[1] "neo_async" 14.6μs[1.00][1.00]
[2] "async" 32.0μs[0.456][2.19]
--------------------------------------
[func-comparator] Executing...
[1] "neo_async" 135μs[1.00][1.00]
[2] "async" 236μs[0.572][1.75]
======================================
[each:map] Comparating...
--------------------------------------
[benchmark] Executing...
[1] "neo_async" 9.44μs[1.00][1.00]
[2] "async" 31.7μs[0.297][3.36]
--------------------------------------
[func-comparator] Executing...
[1] "neo_async" 86.4μs[1.00][1.00]
[2] "async" 238μs[0.363][2.75]
```
9 changes: 6 additions & 3 deletions perf/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ var count = argv.c || argv.count;
var times = argv.t || argv.times;
var target = argv.target; // -t <function name>

var benchmarks = benchmark ? [benchmark] : [
var benchmarks = _.filter([
'benchmark',
'func-comparator'
];
], function(name) {
return benchmark ? RegExp(benchmark).test(name) : name;
});
benchmarks = _.transform(benchmarks, function(result, name) {
result[name] = require('./' + name);
}, {});
Expand Down Expand Up @@ -70,7 +72,8 @@ async.eachSeries(tasks, function(task, name, done) {
var name = data.name;
var mean = data.mean;
var diff = (_.first(array).mean) / mean;
console.log('[' + (++index) + ']', '"' + name + '"', (mean.toPrecision(3)) + 'μs' + '[' + diff.toPrecision(3) + ']');
var rate = mean / (_.first(array).mean);
console.log('[%d] "%s" %sμs[%s][%s]', ++index, name, mean.toPrecision(3), diff.toPrecision(3), rate.toPrecision(3));
});
next();
});
Expand Down

0 comments on commit 97e44f4

Please sign in to comment.