Array push vs splice vs concat vs spread construct (v7)

Revision 7 of this benchmark created on


Setup

let a = Array.from(Array(10000).keys());

Test runner

Ready to run.

Testing in
TestOps/sec
Append using push
let b = [];
for (let i=0; i<100; i++) {
	b.push(...a);
}
ready
Append using splice
let b = [];
for (let i=0; i<100; i++) {
	b.splice(b.length, 0, ...a);
}
ready
Append using concat
let b = [];
for (let i=0; i<100; i++) {
	b=b.concat(a);
}
ready
Append using spread
let b = [];
for (let i=0; i<100; i++) {
	b=[...b, ...a];
}
ready
Append using push with apply
let b = [];
for (let i=0; i<100; i++) {
	Array.prototype.push.apply(b, a);
}
ready

Revisions

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