Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Zen vs Stack vs Stack2
var STACKSIZE=1;
var zen=require('zen');
var stack=require('stack');
var stack2=require('stack2');
var mod=function(a,b,next){next();}
var middles=[];
for (var i=0;i<STACKSIZE;i++){
middles.push(mod);
}
var errorHandler=function(a,b,err){
return;
}
var zenApp=zen.apply(this,middles);
zenApp.errorHandler=errorHandler;
stack.errorHandler=errorHandler;
var stackApp=stack.apply(this,middles);
stack2.errorHandler=errorHandler;
var stack2App=stack2.apply(this,middles);
var Benchmark = require('benchmark');
var suite = new Benchmark.Suite;
// add tests
suite.add('Zen', function() {
zenApp(null,null);
})
.add('Stack', function() {
stackApp(null,null);
})
.add('Stack2', function() {
stack2App(null,null);
})
// add listeners
.on('cycle', function(bench) {
console.log(String(bench));
})
.on('complete', function() {
console.log('Fastest is ' + this.filter('fastest').pluck('name'));
})
// run async
.run(true);
STACKSIZE=1
$ node bench.js
Zen x 351,228 ops/sec ±7.00% (65 runs sampled)
Stack x 2,423,546 ops/sec ±1.73% (74 runs sampled)
Stack2 x 1,611,787 ops/sec ±3.07% (68 runs sampled)
Fastest is Stack
STACKSIZE=25
$ node bench.js
Zen x 14,993 ops/sec ±6.65% (68 runs sampled)
Stack x 109,575 ops/sec ±1.78% (76 runs sampled)
Stack2 x 78,496 ops/sec ±1.69% (75 runs sampled)
Fastest is Stack
STACKSIZE=50
$ node bench.js
Zen x 8,395 ops/sec ±1.60% (76 runs sampled)
Stack x 53,659 ops/sec ±1.77% (75 runs sampled)
Stack2 x 35,124 ops/sec ±1.38% (71 runs sampled)
Fastest is Stack
STACKSIZE=500
$ node bench.js
Zen x 770 ops/sec ±4.75% (71 runs sampled)
Stack x 4,043 ops/sec ±8.91% (62 runs sampled)
Stack2 x 43.34 ops/sec ±6.97% (41 runs sampled)
Fastest is Stack
STACKSIZE=1000
$node bench.js
Zen x 400 ops/sec ±3.80% (74 runs sampled)
Stack x 2,437 ops/sec ±1.93% (75 runs sampled)
Stack2 x 5.34 ops/sec ±16.08% (6 runs sampled)
Fastest is Stack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.