Canvas save-restore (v5)

Revision 5 of this benchmark created by Eric on


Preparation HTML

<canvas id="myCanvas" width="320" height="240"></canvas>
<script>
  var str = "@abcdefghijklmnopqrstuvwxyz";
  var myCanvas = document.getElementById("myCanvas");
  var context2d = myCanvas.getContext("2d");
  var r = [];
  var index = 0;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
save-restore
context2d.save();
context2d.translate(1, 2);
context2d.rotate( 3.65 );
context2d.restore();
ready
manual reset
context2d.translate(1, 2);
context2d.rotate( 3.65 );
r[index++] = 3.65 ;
context2d.rotate( -r[index--] );
context2d.translate(-1, -2);
ready

Revisions

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