concat push (v13)

Revision 13 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
var c = a.slice();
c.concat(b);
ready
push-apply
var c = a.slice();
Array.prototype.push.apply(c, b);
ready
push cached
var c = a.slice();
push.apply(c, b);
ready
empty array concat
var c = [].concat(a, b);
ready
empty array push-apply
var c = Array.prototype.push.apply([], a, b);
ready
empty array cached
var c = push.apply([], a, b);
ready

Revisions

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