Array creation vs modification

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var a = [1, 2, 3, 4, 5, 6]
};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Creation
a = [7, 8, 9, 10, 11, 12]
pending…
Modification of 2 values
a[1] = 7
a[3] = 8
pending…
Modification of 3 values
a[1] = 7
a[3] = 8
a[5] = 9
pending…
Modification of 4 values
a[0] = 7
a[1] = 8
a[3] = 8
a[5] = 10
pending…
Modification of 5 values
a[0] = 7
a[1] = 8
a[3] = 9
a[4] = 10
a[5] = 11
pending…
Modification of 6 values
a[0] = 7
a[1] = 8
a[2] = 9
a[3] = 10
a[4] = 11
a[5] = 12
pending…

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

Compare results of other browsers

0 comments

Add a comment