Skip to content

Commit

Permalink
benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
eldargab committed Mar 28, 2013
1 parent e793158 commit 893676b
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 2 deletions.
7 changes: 7 additions & 0 deletions Makefile
@@ -0,0 +1,7 @@
test:
@./node_modules/.bin/mocha

bench:
@node bench.js

.PHONY: test bench
56 changes: 56 additions & 0 deletions 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})
5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -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",
Expand All @@ -21,7 +21,8 @@
"devDependencies": {
"test-log": "*",
"mocha": "*",
"should": "*"
"should": "*",
"benchmark": "*"
},
"author": "Eldar Gabdullin <eldargab@gmail.com>",
"license": "MIT"
Expand Down

0 comments on commit 893676b

Please sign in to comment.