Skip to content
/ bhdr Public

benchmark utility powered by hdr histograms, for node

License

Notifications You must be signed in to change notification settings

mcollina/bhdr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bhdr  Build Status

Benchmark utility powered by hdr histograms, for node.

It is API-compatible with fastbench.

Install

npm install bhdr

Usage

'use strict'

var bench = require('bhdr')

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

$ node example.js
benchSetTimeout: 1 ops/ms +-0.16
benchSetImmediate: too fast to measure
benchNextTick: too fast to measure
benchSetTimeout: 1 ops/ms +-0.11
benchSetImmediate: too fast to measure
benchNextTick: too fast to measure

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)

Acknowledgements

This project is kindly sponsored by nearForm.

License

MIT

About

benchmark utility powered by hdr histograms, for node

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published