Canvas one stroke vs multiple strokes (v2)

Revision 2 of this benchmark created on


Preparation HTML

<canvas id="c" width="10" height="1" />
<script>
  var canvas = document.getElementById('c'),
      ctx = canvas.getContext('2d');
  
  ctx.strokeStyle = 'red';
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
one stroke
ctx.moveTo(0, 0);
for (var i = 1; i <= 100; i++) {
 ctx.lineTo(i, 0);
}
ctx.stroke();
ready
many strokes
ctx.moveTo(0, 0);
for (var i = 1; i <= 100; i++) {
 ctx.lineTo(i, 0);
 ctx.stroke();
}
ready

Revisions

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