Path rects vs fillrects (v8)

Revision 8 of this benchmark created by Boris on


Preparation HTML

<canvas id="canvas" width="300" height="300"></canvas>
<script>
  canvas = document.getElementById("canvas");
  ctx = canvas.getContext('2d');
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
path rect
ctx.fillStyle = 'rgb(255, 0, 0)';
ctx.beginPath();
for (var i = 0; i < 1000; i++) {
  ctx.rect(i, i, i, i);
}
ctx.closePath();
ctx.fill();
ready
fillRect
ctx.fillStyle = 'rgb(0, 255, 0)';
for (var i = 0; i < 1000; i++) {
  ctx.fillRect(i, i, i, i);
}
ready

Revisions

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