From bab02dca06645f713d15e85c484ee1cb935b47d1 Mon Sep 17 00:00:00 2001 From: Mike Nason Date: Tue, 10 Jan 2017 15:43:48 -0500 Subject: [PATCH] Add benchmark vs naked bunyan --- package.json | 2 ++ test/benchmark/index.js | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 test/benchmark/index.js diff --git a/package.json b/package.json index 989393f..52f67ab 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "main": "dist/node.js", "browser": "dist/client.js", "scripts": { + "benchmark": "node test/benchmark", "test": "npm run test:browser && npm run test:node && npm run test:leakage", "tdd": "npm-run-all --parallel test:*:tdd", "test:ci": "npm run test:browser && npm run test:node:ci", @@ -87,6 +88,7 @@ "babel-polyfill": "6.20.0", "babel-preset-es2015": "6.18.0", "babel-preset-stage-0": "6.16.0", + "benchmark": "2.1.3", "chai": "3.5.0", "coveralls": "2.11.15", "documentation": "4.0.0-beta11", diff --git a/test/benchmark/index.js b/test/benchmark/index.js new file mode 100644 index 0000000..551fb2f --- /dev/null +++ b/test/benchmark/index.js @@ -0,0 +1,35 @@ +/* eslint-disable no-console */ + +const Benchmark = require('benchmark') +const bunyan = require('bunyan'); +const WeLogger = require('../..'); + +var suite = new Benchmark.Suite(); + +const weLogger = new WeLogger({ stdout: false }); +const bunyanLogger = bunyan.createLogger({ name: 'bunyan', streams: [] }); + +suite + .add('we-js-logger', function() { + weLogger.info('hello world') + }) + .add('we-js-logger child', function() { + const log = weLogger.child(); + log.info('hello world'); + }) + .add('bunyan', function() { + bunyanLogger.info('hello world'); + }) + .add('bunyan child', function() { + const log = bunyanLogger.child(); + log.info('hello world'); + }) + // add listeners + .on('cycle', function(event) { + console.log(String(event.target)); + }) + .on('complete', function() { + console.log('Fastest is ' + this.filter('fastest').map('name')); + }) + // run async + .run({ 'async': true }); \ No newline at end of file