Socket
Socket
Sign inDemoInstall

ben

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ben

simple timing benchmarks for synchronous and asynchronous code


Version published
Weekly downloads
120
decreased by-29.41%
Maintainers
1
Install size
4.56 kB
Created
Weekly downloads
 

Readme

Source

ben

Benchmark synchronous and asynchronous snippets simply.

ben the big

examples

synchronous

var ben = require('ben');

var ms = ben(function () {
    JSON.parse('[1,2,3]')
});

console.log(ms + ' milliseconds per iteration');

output:

0.0024 milliseconds per iteration

asynchronous

var ben = require('ben');

var test = function (done) {
    setTimeout(done, 10);
};

ben.async(test, function (ms) {
    console.log(ms + ' milliseconds per iteration');
});

output:

10.39 milliseconds per iteration

methods

ben(times=10000, testFn)

Return how many milliseconds it takes to execute testFn.

testFn will be executed times many times.

alias: ben.sync()

ben.async(times=100, testFn, cb)

Compute how many milliseconds it takes to complete the asynchronous function testFn. testFn(done) will be called with a done callback to move along to the next iteration.

After testFn is run times many times, cb will be called with the number of milliseconds on average that testFn took to finish.

install

With npm, do:

npm install ben

Keywords

FAQs

Last updated on 21 Aug 2011

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc