Array push() vs unshift() (v9)

Revision 9 of this benchmark created on


Description

Tests the performance difference of using two different ways of filling arrays at the start. The two TCs produce the same result. We need a lot of elements to see the real difference.

Test runner

Ready to run.

Testing in
TestOps/sec
push()
var a = [];

for (var i = 0; i++ < 10000;)
  a.push(i);

for (var i = 0; i++ < 10000;)
  a.shift();
 
ready
unshift()
var a = [];

for (var i = 0; i++ < 10000;)
  a.unshift(i);

for (var i = 0; i++ < 10000;)
  a.pop();
 
ready

Revisions

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