Batching Line Drawing Calls (v16)

Revision 16 of this benchmark created on


Description

Compares drawing a simple shape out of multiple lines compared to one polyline.

This version tests both stroking and filling using polylines.

Preparation HTML

<canvas id="c" width="640" height="480"></canvas>
<script>
  var canvas = document.getElementById('c');
  var context = canvas.getContext('2d');
  context.strokeStyle = 'black';
  context.fillStyle = 'black';
</script>

Setup

context.clearRect(0, 0, canvas.width, canvas.height);

Test runner

Ready to run.

Testing in
TestOps/sec
multiple paths
context.beginPath();
context.moveTo(20, 100);
context.lineTo(220, 100);
context.lineTo(220, 380);
context.lineTo(20, 380);
context.closePath();
context.fill();
context.stroke();

context.beginPath();
context.moveTo(220, 100);
context.lineTo(420, 100);
context.lineTo(420, 380);
context.lineTo(220, 380);
context.closePath();
context.fill();
context.stroke();

context.beginPath();
context.moveTo(420, 100);
context.lineTo(620, 100);
context.lineTo(620, 380);
context.lineTo(420, 380);
context.closePath();
context.fill();
context.stroke();
ready
one path, multiple subpaths
context.beginPath();
context.moveTo(20, 100);
context.lineTo(220, 100);
context.lineTo(220, 380);
context.lineTo(20, 380);
context.closePath();
context.moveTo(220, 100);
context.lineTo(420, 100);
context.lineTo(420, 380);
context.lineTo(220, 380);
context.closePath();
context.moveTo(420, 100);
context.lineTo(620, 100);
context.lineTo(620, 380);
context.lineTo(420, 380);
context.closePath();
context.fill();
context.stroke();
ready

Revisions

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