Concat vs Push

Benchmark created on


Setup

let arr1 = [...Array(64_000)].map(() => Math.random());
let arr2 = [...Array(64_000)].map(() => Math.random());

Test runner

Ready to run.

Testing in
TestOps/sec
concat
let total = [];
total = total.concat(arr1);
total = total.concat(arr2);
ready
push (spread)
let total = [];
total.push(...arr1);
total.push(...arr2);
ready
push (apply)
let total = [];
Array.prototype.push.apply(total, arr1);
Array.prototype.push.apply(total, arr2);
ready

Revisions

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