new array vs splice vs reuse (v3)

Revision 3 of this benchmark created by Cedric Pinson on


Description

Different method to replace the content of an array...

Preparation HTML

<script>
  var a;
</script>

Test runner

Ready to run.

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

Revisions

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