Splicing a single value (v44)

Revision 44 of this benchmark created by c on


Setup

var arr = [];
    for (var i = 0; i < 10000; i++) {
     arr.push(i);
    };
    var half = Math.floor(arr.length / 2);
    
    var obj1 = {};
    for (var i = 0; i < 10000; i++){
     obj1[i] = i;
    };
      
    function randomInt(max) {
     return Math.floor(Math.random() * (max + 1));
    };

Test runner

Ready to run.

Testing in
TestOps/sec
Splice insertion at half-way point
arr.splice(half, 0, 'foo');
ready
Splice insertion at a random point
arr.splice(randomInt(arr.length), 0, 'foo');
ready
Push
arr.push('foo');
ready
delete obj
delete obj1[5000];
ready

Revisions

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