@mariocasciaro/benchpress
No fuss benchmarking
Last updated 3 years ago by mariocasciaro .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @mariocasciaro/benchpress 
SYNC missed versions from official npm registry.

Synopsis

No fuss benchmarking for Node.js.

NPM

Build Status Dependency Status

Usage

var Benchpress = require('@mariocasciaro/benchpress');

var suite = new Benchpress({
  // iterations: 1000   <--- 1000 by default
});


suite
  .add('Benchmark name', {
    beforeAll: function() {
      // Run before the benchmark is started
    },
    beforeEach: function() {
      // Run before each iteration
    },
    fn: function() {
      // The code to profile
    },
    afterEach: function() {
      // Run after each iteration
    },
    afterAll: function() {
      // Run after the benchmark finishes
    }
  })
  .add('Async benchmark', function() {
    beforeAll: function(done) {
      // Run code asynchronously before the benchmark starts
      done();
    },
    fn: function(done) {
      // Profile async code too
      done();
    },
    afterEach: function(done) {
      // any function can be asynchronous...
      done();
    },
    //specify iterations per benchmark
    iterations: 300
  })
  //don't forget to run the suite!!!
  .run();

The code above will print in the console something like this:

Starting suite.
Benchmark 'Benchmark name': 374812 ops/sec (1000 iterations)
Benchpress 'Async benchmark': 126432 ops/sec (300 iterations)
Run complete.

Current Tags

  • 0.2.0                                ...           latest (3 years ago)

2 Versions

  • 0.2.0                                ...           3 years ago
  • 0.1.3                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 6
Dependencies (2)
Dev Dependencies (2)
Dependents (1)

Copyright 2014 - 2017 © taobao.org |