new array vs splice vs slice (v2)

Revision 2 of this benchmark created by Bruno Garcia on


Preparation HTML

<script>
  var a;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Slice
a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
a = a.slice(10);
ready
New
a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
a = [];
ready
Splice
a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
a.splice(0, 10);
ready
Zero length
a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
a.length = 0;
ready

Revisions

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