String vs Array concat (v10)

Revision 10 of this benchmark created on


Description

A test case to see if concatenating an array instead of a string for an inflate library would perform better, based on this post: http://my.opera.com/emoller/blog/2011/05/01/javascript-performance

Test runner

Ready to run.

Testing in
TestOps/sec
String Concat
var dest = 'apple';
while (dest.length < 100) {
 var offs = dest.length - 5;
 for (var i = offs; i < offs + 10; ++i)
 dest += dest[i];
}
ready
Array Concat
var dest = ['a', 'p', 'p', 'l', 'e'];
while (dest.length < 100) {
 var offs = dest.length - 5;
 for (var i = offs; i < offs + 10; ++i)
 dest.push(dest[i]);
}
dest = dest.join();
ready

Revisions

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