array merging

Benchmark created on


Setup

const testArray = Array.from({ length: 200 }, (v, i) => i)

Test runner

Ready to run.

Testing in
TestOps/sec
spread
let result = []
for (let i = 0; i < 150; i++) {
	result = [...result, ...testArray];
}
ready
concat
let result = []
for (let i = 0; i < 150; i++) {
	result = result.concat(testArray);
}
ready
push spread
let result = []
for (let i = 0; i < 150; i++) {
	result.push(...testArray);
}
ready
push apply
let result = []
for (let i = 0; i < 150; i++) {
	Array.prototype.push.apply(result, testArray);
}
ready

Revisions

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