Test array read

Benchmark created on


Setup

var arr = new Array(10000);
for (let i = 0; i < arr.length; ++i) {
	arr[i] = Math.random();
}

function consumeVal(x) {}

Test runner

Ready to run.

Testing in
TestOps/sec
Shifting
var p;
while (p = arr.shift()) {
	consumeVal(p);
}
ready
Popping
var p;
while (p = arr.pop()) {
	consumeVal(p);
}
ready
Length check shift
while (arr.length) {
	consumeVal(arr.shift());
}
ready
Length check pop
while (arr.length) {
	consumeVal(arr.pop());
}
ready

Revisions

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