Skip to content

Commit

Permalink
Merge pull request #5 from keis/matcha
Browse files Browse the repository at this point in the history
adding a simple formatter benchmark
  • Loading branch information
keis committed Jan 28, 2015
2 parents 85fa289 + 106c451 commit d0b1050
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -10,7 +10,8 @@
"author": "David Keijser <keijser@gmail.com>",
"license": "MIT",
"scripts": {
"test": "mocha --require test/bootstrap.js --compilers coffee:coffee-script/register --recursive test/unit"
"test": "mocha --require test/bootstrap.js --compilers coffee:coffee-script/register --recursive test/unit",
"bench": "coffee -c test/benchmark.coffee ; matcha test/benchmark.js"
},
"devDependencies": {
"chai": "^1.9.1",
Expand All @@ -20,6 +21,7 @@
"grunt-contrib-watch": "^0.6.1",
"grunt-docco": "^0.3.3",
"istanbul": "^0.3.5",
"matcha": "^0.6.0",
"mocha": "^2.0.1",
"sinon": "^1.10.0"
},
Expand Down
23 changes: 23 additions & 0 deletions test/benchmark.coffee
@@ -0,0 +1,23 @@

suite 'rapidus.format', ->
{createFormatter} = require '../lib/sinks'

record =
foo: 'foo-text'
bar: 'bar-text'
level: -> 'WARNING'

set 'iterations', 100000

simple = createFormatter ':foo'
complex = createFormatter '[:foo] :bar :level'
big = createFormatter '-:foo-:bar-:foo-:foo-:bar-:foo-:bar-:foo-:bar'

bench 'simple attribute', ->
simple record

bench 'complex format string', ->
complex record

bench 'big format string', ->
big record

0 comments on commit d0b1050

Please sign in to comment.