Splicing a single value - scalability (v34)

Revision 34 of this benchmark created on


Setup

var smallarr = [];
    var bigarr = [];
    var hugearr = [];
    
    for (var i = 0; i < 1; i++) {
     smallarr.push(i);
    };
    
    for (var i = 0; i < 1000000; i++) {
     bigarr.push(i);
    };
    
    for (var i = 0; i < 2000000; i++) {
     hugearr.push(i);
    };
    
    // var half = Math.floor(arr.length / 2);

Test runner

Ready to run.

Testing in
TestOps/sec
small splice
var n = Math.floor(smallarr.length / 2)
smallarr.splice(n, 0, n);
ready
large splice
var n = Math.floor(bigarr.length / 2)
bigarr.splice(n, 0, n);
ready
huge splice
var n = Math.floor(hugearr.length / 2);
hugearr.splice(n, 0, n);
ready
Shift
var n = Math.floor(hugearr.length / 2);
hugearr.shift(n);
ready
Push
var n = Math.floor(hugearr.length / 2);
hugearr.push(n);
ready

Revisions

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