Splicing a single value (v31)

Revision 31 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, 0, 'foo');
ready
Push
getArr().push('foo');
ready
UnShift
getArr().unshift('foo');
ready
Splice insertion at front
getArr().splice(0, 0, 'foo');
ready

Revisions

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