Splicing a single value (v22)

Revision 22 of this benchmark created on


Preparation HTML

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

Test runner

Ready to run.

Testing in
TestOps/sec
Splice insertion at half-way point
getArr().splice(half, 123, 'foo');
ready
Push
getArr().push('foo');
ready
Shift
getArr().shift('foo');
ready

Revisions

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