Array item removal (v2)

Revision 2 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Swap + length
const arr = Array(2000).fill().map((_, i)=> ({ i }));

for (let i = 0; i < 200; i++) {
	const at = Math.floor(Math.random() * arr.length);

	arr[at] = arr[arr.length - 1];
	arr.length--;
}
ready
Splice
const arr = Array(2000).fill().map((_, i)=> ({ i }));

for (let i = 0; i < 200; i++) {
	const at = Math.floor(Math.random() * arr.length);
	arr.splice(at, 1);
}
ready
Swap + length using .at(-1)
const arr = Array(2000).fill().map((_, i)=> ({ i }));

for (let i = 0; i < 200; i++) {
	const at = Math.floor(Math.random() * arr.length);

	arr[at] = arr.at(-1);
	arr.length--;
}
ready

Revisions

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