Nested loops

JavaScript performance comparison

Test case created by Tim Severien

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var i, x, y, size = Math.pow(2, 10);
};
</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
Nested
for (x = 0; x < size; x++) {
  for (y = 0; y < size; y++) {
    i = y * size + x;
  }
}
pending…
Flat
var sqr = size * size;

for (i = 0; i < sqr; i++) {
  x = i % size;
  y = Math.floor(i / size);
}
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