Does size matter?

Benchmark created by Casey on


Description

Does the length of an array matter if we're only accessing the first couple elements?

Preparation HTML

<script>
    var array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
    
    var array_large = [];
    for (var i = 0; i < 1e6; i++)
       array_large[i] = i;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Small
m = array[5]
ready
Large
m = array_large[5]
ready
Large (end)
m = array_large[999995]
ready

Revisions

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