Cross Origin Canvas

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var src = "http://ii.cdn.tf/u7224481/c128x128/fm4q62.jpg/15gzeey.jpg";
    var img = new Image();
    var D = 4,
        S = 128;
    img.src = src;
   
   
    function maze1(image) {
      var canvas = document.createElement('canvas'),
          ctx = canvas.getContext('2d'),
          x, y, i, j;
      for (x = 0; x < S; x += D) {
        for (y = 0; y < S; y += D) {
          for (i = 0; i < D; i += 1) {
            for (j = 0; j < D; j += 1) {
              ctx.drawImage(image, x, y, D, D, x + i, y + j, 1, 1);
            }
          }
        }
      }
      return canvas;
    }
   
    function maze2(image) {
      var canvas = document.createElement('canvas'),
          ctx = canvas.getContext('2d'),
          x, y;
      for (x = 0; x < S; x += D) {
        for (y = 0; y < S; y += D) {
          ctx.drawImage(image, x, y, 1, 1, 150 + x, y, D, D);
        }
      }
      return canvas;
    }
};
</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
algorithm1
maze1(img);
pending…
algorithm2
maze2(img);
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