array push/shift vs indexed reads/writes

Benchmark created on


Setup

var testArray1 = Array(20000).fill(0);

var testArray2 = Array(20000).fill(0);
var index = 0;

Test runner

Ready to run.

Testing in
TestOps/sec
push/shift
testArray1.push(testArray1.shift());
ready
indexed read/write
testArray2[index % testArray2.length] = testArray2[(index + 1) % testArray2.length];

index++;
ready

Revisions

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