ints/values in/out of array bounds

JavaScript performance comparison

Test case created by NathanJAdams

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  let control = [];
  let outofbounds = [];
  let holey = [];
  let nans = [];
  let obj = new Array(20);
  let undefineds = [];
  
  for (var i=0; i<20; i++) {
    control[i] = i;
    outofbounds[i] = i;
    if (i % 10 == 0) holey[i] = i;
    nans[i] = NaN;
    obj[i] = i;
  }
  

};
</script>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Control
for (var i=0; i<20; i++) {
  if (control[i] % 100 == 100) return true;
}
pending…
Out of bounds
for (var i=10; i<30; i++) {
  if (outofbounds[i] % 100 == 100) return true;
}
pending…
Holey
for (var i=0; i<20; i++) {
  if (holey[i] % 100 == 100) return true;
}
pending…
NaNs
for (var i=0; i<20; i++) {
  if (nans[i] % 100 == 100) return true;
}
pending…
Object
for (var i=0; i<20; i++) {
  if (obj[i] % 100 == 100) return true;
}
pending…
Undefineds
for (var i=0; i<20; i++) {
  if (undefineds[i] % 100 == 100) return true;
}
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