Splicing a single value (v13)

Revision 13 of this benchmark created on


Preparation HTML

<script>
  var arr = [];
  for (var i = 0; i < 2000000; i++) {
   arr.push(i);
  };
  var half = Math.floor(arr.length / 2);
  
  function getArr() {
   return arr;
  };
  
  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, 1);
ready
Push
getArr().push('foo');
ready
Shift
getArr().unshift('foo');
ready

Revisions

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