Canvas Draw Image vs fill rect

JavaScript performance comparison

Revision 20 of this test case created by

Preparation code

<canvas id="myCanvas" width="600" height="400"></canvas>
<img id="myImg" src="http://upload.wikimedia.org/wikipedia/commons/f/f0/Pixelart-tv-iso.png" />
      
<script>
Benchmark.prototype.setup = function() {
  var canvas = document.getElementById('myCanvas');
  var ctx = canvas.getContext('2d');
  var img = document.getElementById('myImg');
  ctx.mozImageSmoothingEnabled = false;
  ctx.scale(4, 4);

};
</script>

Preparation code output

<canvas id="myCanvas" width="600" height="400"></canvas> <img id="myImg" src="http://upload.wikimedia.org/wikipedia/commons/f/f0/Pixelart-tv-iso.png" />

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
Fill Rect
ctx.fillRect(0, 0, 10, 10);
pending…
Draw Image
ctx.strokeRect(0, 0, 10, 10);
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