Array push() vs unshift() (v32)

Revision 32 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.

Test runner

Ready to run.

Testing in
TestOps/sec
push
var a = new Array(10000);
a.push(1);
a.push(2);
a.push(3);
a.push(4);
a.push(5);
a.push(6);
a.push(7);
a.push(8);
a.push(9);
a.push(10);
ready
unshift
var a = new Array(10000);
a.unshift(10);
a.unshift(9);
a.unshift(8);
a.unshift(7);
a.unshift(6);
a.unshift(5);
a.unshift(4);
a.unshift(3);
a.unshift(2);
a.unshift(1);
ready
push once
var a = new Array(10000);
a.push(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
 
ready
unshift once
var a = new Array(10000);
a.unshift(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
 
ready

Revisions

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