jh

Benchmark created on


Setup

const ARRAY_MIN = 1000, ARRAY_MAX = 10000;

Test runner

Ready to run.

Testing in
TestOps/sec
concat
function merge_arrays(size) {
	const array0 = Array.from({length}, () => 0);
	const array1 = Array.from({length}, () => 0);
	return array0.concat(array1);
}

for (let idx = ARRAY_MIN; idx <= ARRAY_MAX; ++idx) {
	merge_arrays(idx);
}
ready
push
function merge_arrays(size) {
	const array0 = Array.from({length}, () => 0);
	const array1 = Array.from({length}, () => 0);
	Array.prototype.push.apply(array0, array1);
	return array0;
}

for (let idx = ARRAY_MIN; idx <= ARRAY_MAX; ++idx) {
	merge_arrays(idx);
}
ready
push spread
function merge_arrays(length) {
	const array0 = Array.from({length}, () => 0);
	const array1 = Array.from({length}, () => 0);
	array0.push(... array1);
	return array0;
}

for (let idx = ARRAY_MIN; idx <= ARRAY_MAX; ++idx) {
	merge_arrays(idx);
}
ready

Revisions

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