diff --git a/.travis.yml b/.travis.yml index af4ac88..2aa0377 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,8 @@ before_script: - npm install -g coveralls script: - make ci + - npm run benchmark + - npm run benchmark2 branches: only: - master diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js new file mode 100644 index 0000000..4c3f673 --- /dev/null +++ b/benchmark/benchmark.js @@ -0,0 +1,22 @@ +'use strict'; + +const util = require('util'); +const Benchmark = require('benchmark'); +const LightBright = require('../index'); +const Timing = LightBright.builtins.timing; +LightBright.addFilter(Timing.timer); +LightBright.enable(); + +function a () { + util.inspect({foo: 1}); + let t = Timing.timings(); // eslint-disable-line +} + +const suite = Benchmark.Suite(); +suite +.add('With lightbright', a) +.on('cycle', (event) => console.log(String(event.target))) +.on('complete', () => { + LightBright.disable(); +}) +.run({ 'async': true }); diff --git a/benchmark/benchmark2.js b/benchmark/benchmark2.js new file mode 100644 index 0000000..8b41967 --- /dev/null +++ b/benchmark/benchmark2.js @@ -0,0 +1,15 @@ +'use strict'; + +const util = require('util'); +const Benchmark = require('benchmark'); + +function a () { + util.inspect({foo: 1}); +} + +const suite = Benchmark.Suite(); +suite +.add('Without lightbright', a) +.on('cycle', (event) => console.log(String(event.target))) +.on('complete', () => { }) +.run({ 'async': true }); diff --git a/package.json b/package.json index 868e69d..82eb2e9 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,9 @@ "lint": "eslint lib/*.js test/*.js index.js", "test": "istanbul cover test/runner.js", "prepublish": "nsp check", - "ci": "make ci" + "ci": "make ci", + "benchmark": "node benchmark/benchmark.js", + "benchmark2": "node benchmark/benchmark2.js" }, "keywords": [ "AsyncWrap", @@ -22,6 +24,8 @@ "license": "Apache-2.0", "devDependencies": { "async": "^2.0.0-rc.6", + "bench": "^0.3.6", + "benchmark": "^2.1.2", "cli-color": "^1.1.0", "eslint": "^3.3.1", "eslint-config-semistandard": "^7.0.0-beta.0",