Monday, November 10th, 2008

JSLitmus: Testing JavaScript Performance

Category: Performance, Testing, Utility

Robert Kieffer has announced JSLitmus a tool “designed specifically to allow you to quickly and easily write a JavaScript test (or test suite), run it on any modern browser, and document and share the results.”

To see it in action, Robert writes a test on “++” and plots the results for different browsers, and then draws some conclusions.

The API for creating a test is simple:


  1. JSLitmus.test('Empty function test', function() {});

Once you define your tests you can run them in the page thanks to the popup, and then it will do its thing and give you a Google Chart at the other end of things.

A nice little tool.

Posted by Dion Almaer at 6:20 am

3.4 rating from 10 votes


Comments feed TrackBack URI

Shame he didn’t show the graph for WebKit nightly vs. Safari to see how far SquirrelFish has come! (Below graphs generated on a 2.4GHz MBP)

Safari 3.1.2:
WebKit nightly:

That’s over 10x performance increase!

Comment by spyke — November 10, 2008

@spyke: Robert Kieffer here, the JSLitmus developer. Can you post the same tests, but with the “Normalize results” box unchecked?

The way the scope resolution test works, JSLitmus is getting normalized results by subtracting the time required to do this:

while (count--) {}

… from the time required to do this:

while (count--) {x++;}

… to get the time required to do “x++”. In non-SquirrelFish browsers, resolving “x” takes a lot longer than doing the “++”, so provides meaningful data for how long the resolution process takes. But in the webkit builds that use SquirrelFish, this code is all compiled down to bytecode, which eliminates the variable resolution overhead, so JSLitmus is just measuring the time needed for a native “++” operation. That operation is so ridiculously fast, however, that if there’s any additional overhead associated with the JavaScript interpreter, it will affect the test result accuracy.

CloudDream posted a comment on our blog showing that he’s getting “infinity” operations per second for Google Chrome, which I suspect is doing something similar. The “Infinity” result means that JSLitmus simply isn’t able to detect a significant difference between the calibration loop it uses (the top loop, above) and the loop that runs the test code.

Comment by broofa — November 10, 2008

Leave a comment

You must be logged in to post a comment.