drawImage whole pixels (v42)

Revision 42 of this benchmark created on


Preparation HTML

<canvas id="screen"></canvas><canvas id="screen2"></canvas>
<script>
  var ctx = document.getElementById("screen").getContext("2d");
  var ctx2 = document.getElementById("screen2").getContext("2d");
  var image = document.createElement("img");
  image.src = "http://icons.iconarchive.com/icons/ph03nyx/super-mario/48/Retro-Mushroom-1UP-2-icon.png";
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
whole pixel
ctx.drawImage(image, 0, 0);
ready
sub pixel
ctx2.drawImage(image, 0.5, 0.5);
ready
sub pixel + round
ctx2.drawImage(image, Math.round(0.5), Math.round(0.5));
ready
sub pixel + floor
ctx2.drawImage(image, Math.floor(0.5), Math.floor(0.5));
ready
sub pixel + bitwise floor
ctx2.drawImage(image, 0.5 | 0, 0.5 | 0);
ready

Revisions

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