animation in canvas (v5)

Revision 5 of this benchmark created on


Description

How to move an elment ? save / restore ? translate ? just fillRect ?

Preparation HTML

<canvas id="testCanvas" width="500" height="500">
</canvas>
<script>
  var ctx = document.getElementById("testCanvas").getContext("2d");
  var image = new Image();
  image.src = "http://upload.wikimedia.org/wikipedia/commons/6/63/Wikipedia-logo.png"
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
just drawImage
for (var p = 0; p < 10000; p++) {
  ctx.drawImage(
  image, p, p);
}
ready
translate only
for (var p = 0; p < 10000; p++) {
  ctx.translate(p, p);
  ctx.drawImage(
  image, 0, 0);
  ctx.translate(-p, -p);
}
ready
translate + save / restore
for (var p = 0; p < 10000; p++) {
  ctx.save();
  ctx.translate(p, p);
  ctx.drawImage(
  image, 0, 0);

  ctx.restore();
}
ready

Revisions

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