Splice vs Push/Unshift (v11)

Revision 11 of this benchmark created on


Description

Examining which way of adding new elements into array

Setup

a = [], b = [], c = [], d = [], e = [], pos = 0;

Test runner

Ready to run.

Testing in
TestOps/sec
Splice add at top
a.splice(0,0,1)
 
ready
Unshift
b.unshift(1)
ready
Splice add at bottom 1
c.splice(c.length, 0, 1)
ready
Splice add at bottom 2
d.splice(pos++, 0, 1)
ready
Push
e.push(1)
ready

Revisions

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