Array push() vs unshift() (v8)

Revision 8 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);
a = a.reverse();
ready
unshift()
var a = [];
for (var i = 0; i++ < 10000;)
a.unshift(i);
ready

Revisions

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