Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including benit with all npm packages installed. Try it out:

var benit = require("benit")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

benit v0.0.1-4

A simple, easy, javascript benchmarking library.

benit

A simple, easy, javascript benchmarking library.

Example

var benit = Benit('String Match Benchmark');

// add tests
benit
    .add('RegExp#test', function () {
        return /o/.test('Hello World!');
    })
    .add('String#indexOf', function () {
        return 'Hello World!'.indexOf('o') > -1;
    })
    .add('String#match', function () {
        return !!'Hello World!'.match(/o/);
    })
    .on('start', function () {
        console.log('============================================================');
        console.log(this.name);
        console.log('------------------------------------------------------------');
    })
    .on('test', function (test) {
        console.log(test.toString());
    })
    .on('complete', function () {
        console.log('------------------------------------------------------------');
    })
    // 100000 times, 20 cycles
    .run(100000, 20);

Outputs:

============================================================
String Match Benchmark
------------------------------------------------------------
RegExp#test:   10470000 ops/sec (100000 x 20 ops/ 191 ms)
String#indexOf:   18520000 ops/sec (100000 x 20 ops/ 108 ms)
String#match:   9009000 ops/sec (100000 x 20 ops/ 222 ms)
------------------------------------------------------------

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free