diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..36ee720 --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +test: + @./node_modules/.bin/mocha + +bench: + @node bench.js + +.PHONY: test bench \ No newline at end of file diff --git a/bench.js b/bench.js new file mode 100644 index 0000000..4b3505e --- /dev/null +++ b/bench.js @@ -0,0 +1,56 @@ +var Bench = require('benchmark') +var app = require('./index')() + +app +.set('one', 1) +.set('two', 2) +.set('three', 3) +.set('four', 4) +.set('five', 5) +.def('onedep', function(one) { + return one +}) +.def('fivedeps', function(one, two, three, four, five) { + return one +}) +.def('a', function() { + return 'a' +}) +.def('b', function() { + return 'b' +}) +.def('ab', function(a, b) { + return a + b +}) +.def('async', function(two, done) { + done(null, two) +}) +.def('bone', function(b, one) { + return b + one +}) +.def('computation', function(bone, async, ab, done) { + done(null, bone + async + ab) +}) + +function noop() {} + + +var suite = new Bench.Suite + +suite.add('1 dep', function() { + app.run().eval('onedep', noop) +}) + +suite.add('5 deps', function() { + app.run().eval('fivedeps', noop) +}) + +suite.add('computation', function() { + app.run().eval('computation', noop) +}) + +suite.on('cycle', function(ev, bench) { + console.log(String(ev.target)) +}) + +suite.run({async: true}) \ No newline at end of file diff --git a/package.json b/package.json index 890f538..0427d32 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.4.1", "description": "Make style control flow. Good for complex functions.", "scripts": { - "test": "mocha -R spec" + "test": "mocha" }, "repository": { "type": "git", @@ -21,7 +21,8 @@ "devDependencies": { "test-log": "*", "mocha": "*", - "should": "*" + "should": "*", + "benchmark": "*" }, "author": "Eldar Gabdullin ", "license": "MIT"