Splicing a single value at end (v6)

Revision 6 of this benchmark created on


Preparation HTML

<script>
  var arr = [];
  for (var i = 0; i < 10000; i++) {
   arr.push(i);
  };
  
  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 end
var arr = getArr();
arr.splice(arr.length, 0, '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.