array clearing

Benchmark created on


Setup

var arr = []

let i = 0
while (i < 10_000) {
	arr.push({ obj: i })
	i++;
}

Test runner

Ready to run.

Testing in
TestOps/sec
a = [];
a = []; // 37% slower
ready
a.length = 0;
a.length = 0; // 89% slower
ready
a.splice(0, a.length) // 97% slower
a.splice(0, a.length)  // 97% slower
ready
while pop
while (a.length > 0) {
    a.pop();
} // Fastest
ready

Revisions

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