Canvas offscreen rendering

JavaScript performance comparison

Test case created by Bruno Garcia

Preparation code

<canvas id="canvas" width="760" height="500"></canvas>
<script>
  var canvas = document.getElementById("canvas");
  var ctx = canvas.getContext("2d");
  var man = new Image();
  man.src = "http://aduros.emufarmers.com/tmp/man.png";
  
  var background = new Image();
  background.onload = function () {
      ctx.fillStyle = ctx.createPattern(background, "repeat");
  };
  background.src = "http://aduros.emufarmers.com/tmp/background.jpg";
  
  //
  // Wait a few seconds for these images to load before starting the tests!
  //
</script>
    

Preparation code output

<canvas id="canvas" width="760" height="500"></canvas>

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
drawImage
// Fully on screen
ctx.drawImage(man, 0, 0);
pending…
drawImage offscreen
// Fully off screen
ctx.drawImage(man, -200, 0);
pending…
CanvasPattern
// Fully on screen
ctx.fillRect(0, 0, canvas.width, canvas.height);
pending…
CanvasPattern offscreen
// Fully off screen
ctx.fillRect(canvas.width, 0, canvas.width, canvas.height);
pending…
drawImage partial
// Partially on screen
ctx.drawImage(man, -16, 0);
pending…
CanvasPattern partial
// Partially on screen
ctx.fillRect(0.5*canvas.width, 0, canvas.width, canvas.height);
pending…

Compare results of other browsers

Revisions

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

0 Comments