JavaScript performance comparison

Test case created by Stoyan

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
var res = '',
    count = 10000;
while (count--) {
 res += 'a';
var res = [],
    count = 10000;
while (count--) {
res = res.join('');

Compare results of other browsers


You can edit these tests or add even more tests to this page by appending /edit to the URL.


galambalazs commented :

JSPerf is wrong here. It's faster to use join by the order of 10 in IE 7. And IE 6-7 have ~18% market share combined. join is still relevant. Please refer to:

John-David Dalton commented :

@galambalazs The problem is with Browserscope. It erroneously detects IE8 (running as IE7) as IE7. This caused the higher ops/sec for concat() to be recorded under IE7 instead of IE8. I will submit a bug report to Browserscope ASAP. Thanks for the heads up.

There are several reasons for different results between Benchmark.js (jsPerf), JSLitmus, and your custom test. The biggest difference is Benchmark.js compiles tests unrolled to avoid calibrating test loops and additional function calls. This helps reduce factors that contribute to inaccurate results. Benchmark.js also performs statistical analysis on the results and attempts to reduce the margin of error (at a 95% confidence level) of each result to 1% of the mean. Your custom test should run for at least 750ms, in IE, (instead of 200ms) to reduce the percent uncertainty for the measurement to 1%. This is because IE’s smallest unit of measure is ~15ms (15ms / 2 → 7.5ms / 0.01 → 750ms).