Benchmark Suite Runner for benchmark.js

Benchmark Suite Runner for benchmark.js

npm install benchrunner
bower install benchrunner

You can write a suite like this:

(function(root) {

    var suites = root.benchrunner.suites;;

        .add('String.replace', function() {
            '   foo   '.replace(/^\s+|\s+$/g, '');
        .add('String.trim', function() {
            '   foo   '.trim();

}(typeof global == 'object' && global || this));

Now you can run them from CLI or in the browser really easy:

Currently only PhantomJS is supported.

phantomjs benchrunner.js suite1.js suite2.js

From the root of your project, that would become e.g.:

phantomjs ./node_modules/benchrunner/benchrunner.js benchmarks/my-suite.js

Or, if you install globally (i.e. npm install -g benchrunner):

benchrunner benchmarks/my-suite.js

Just point your browser at the runner page, e.g.


See examples/basic.html for an example (you need to include a few scripts).

Heavily inspired by Lo-Dash's benchmark suite runner.

MIT licensed