Summary
The open-source WebKit project recently released SunSpider, a new client-side JavaScript performance benchmark. Jeff Atwood took SunSpider for a spin, comparing JavaScript execution in four browsers.
Advertisement
To the degree Ajax applications rely on client-side code, a browser's JavaScript performance can have a big impact on users' perception of an application's responsiveness. Unfortunately, measuring JavaScript performance is a complex task, since JavaScript code often must interact with various parts of the browser, such as the DOM, networking, or graphics rendering components.
The project that develops the open-source WebKit browser, on which products such as the Safari browser and Adobe's AIR are based, recently released SunSpider, to date the most comprehensive set of JavaScript benchmarks. According to the project's documentation, SunSpiders differs from other browser JavaScript benchmarks in three main ways:
Real World
This test mostly avoids microbenchmarks, and tries to focus on the kinds of actual problems developers solve with JavaScript today, and the problems they may want to tackle in the future as the language gets faster. This includes tests to generate a tagcloud from JSON input, a 3D raytracer, cryptography tests, code decompression, and many more examples. There are a few microbenchmarkish things, but they mostly represent real performance problems that developers have encountered.
Balanced
This test is balanced between different areas of the language and different types of code. It's not all math, all string processing, or all timing simple loops. In addition to having tests in many categories, the individual tests were balanced to take similar amounts of time on currently shipping versions of popular browsers.
Statistically Sound
One of the challenges of benchmarking is knowing how much noise you have in your measurements. This benchmark runs each test multiple times and determines an error range (technically, a 95% confidence interval). In addition, in comparison mode it tells you if you have enough data to determine if the difference is statistically significant.
Jeff Atwood used SunSpider to compare the performance of four browsers, including Safari on Windows. While each browser shines in certain areas, Safari and Opera tended to perform better than IE 7 and Firefox in Atwood's test.
The SunSpider tests can be executed on any browser.
What do you think of JavaScript performance in modern browsers?