fastbench
the simplest benchmark you can run on node
Last updated 9 years ago by matteo.collina .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install fastbench 
SYNC missed versions from official npm registry.

fastbench  Build Status

The simplest benchmark you can run on node

Install

npm install fastbench

Usage

'use strict'

var bench = require('fastbench')

var run = bench([
  function benchSetTimeout (done) {
    setTimeout(done, 0)
  },
  function benchSetImmediate (done) {
    setImmediate(done)
  },
  function benchNextTick (done) {
    process.nextTick(done)
  }
], 1000)

// run them two times
run(run)

Output:

benchSetTimeout*1000: 1363ms
benchSetImmediate*1000: 4ms
benchNextTick*1000: 1ms
benchSetTimeout*1000: 1365ms
benchSetImmediate*1000: 4ms
benchNextTick*1000: 0ms

You can disable colors by passing a --no-color flag to your node script.

API

bench(functions, iterations)

Build a benchmark for the given functions and that precise number of iterations. It returns a function to run the benchmark.

The iterations parameter can also be an Object, in which case it acceps two options:

  • iterations: the number of iterations (required)
  • max: is a an alias for iterations
  • color: if the output should have color (default: true)

License

MIT

Current Tags

  • 1.0.1                                ...           latest (9 years ago)

3 Versions

  • 1.0.1                                ...           9 years ago
  • 1.0.0                                ...           9 years ago
  • 0.0.1                                ...           9 years ago
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 2
Last Month 0
Dependencies (2)
Dev Dependencies (5)

Copyright 2013 - present © cnpmjs.org | Home |