Array member vs shift

JavaScript performance comparison

Test case created by lonesomeday

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var arr = ['foo', 'bar', 'zoom'],
        var1 = undefined,
        var2 = undefined,
        var3 = undefined;
};
</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
Array member
var1 = arr[0];
var2 = arr[1];
var3 = arr[2];
pending…
Shift
var1 = arr.shift();
var2 = arr.shift();
var3 = arr.shift();
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