concat push (v7)

Revision 7 of this benchmark created on


Description

Part of the following article: http://wellcaffeinated.net/articles/your-javascript-is-slow-common-and-not-so-common-optimizations

Setup

var a = ['the quick brown fox', 'jumps over the lazy dog'];
    var b = ['and the lazy dog', 'does not mind'];
    var push = Array.prototype.push;

Test runner

Ready to run.

Testing in
TestOps/sec
concat
a = a.concat(b);
ready
push-apply
push.apply(a, b);
 
ready
Copy, then concat (new instance)
var c = a.slice(0);
push.apply(c, b);
ready
unshift
var c = a.slice(0);
c.unshift('message');
ready

Revisions

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