Home

Awesome

jslitmus: JavaScript benchmark testing made easy

jslitmus is copyright(C) Robert Kieffer, 2010. It is available for use under the MIT opensource license.

Examples

Better/richer examples are forthcoming. For now, checkout test/example.htm. It demonstrates how to setup and run tests, how to listen for test results, and how to get a google graph link for the results. (It even shows how to shorten that URL via bit.ly)

In a web page:

<script src="jslitmus.js"></script>
<script>
// Create a test to see how fast Array.join() is on 10K elements
var a = new Array(10000);
jslitmus.test('Join 10K elements', function() {
    a.join(' ');
});

// Log the test results
jslitmus.on('complete', function(test) {
    console.log(test);
});

// Run it!
jslitmus.runAll();
</script>

Outputs:

>>> Join 10K elements, f = 6.305khz (5.12k/0.812secs)

I.e. Our test function runs at a "frequency" of 6,305 times per second.

In a Node.js

var sys = require('sys');
var jslitmus = require('./jslitmus.js');

var a = new Array(10000);
jslitmus.test('Join 10K elements', function() {
    a.join(' ');
});

// Log the test results
jslitmus.on('complete', function(test) {
    sys.log(test);
});

// Run it!
jslitmus.runAll();

jslitmus API

In addition to the following, jslitmus also inherits the EventEmitter API, below.

Properties

Methods

Events

Also, the following events are forwarded from any test created with jslitmus.test(). See the corresponding jslitmus.Test API event documentation for details:

jslitmus.Test API

In addition to the following, jslitmus.Test also inherits the EventEmitter API, below.

Properties

Methods

Events

EventEmitter API

The EventEmitter API is not exposed directly - it is only available through jslitmus and jslitmus.Test objects that inherit it.

Properties

Methods