Batching Line Drawing Calls (v34)

Revision 34 of this benchmark created on


Description

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

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.lineWidth=1;
context.lineCap="round";
context.lineJoin="round";
</script>

Setup

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

Test runner

Ready to run.

Testing in
TestOps/sec
multiple lines
context.beginPath();
context.moveTo(100, 100);
context.lineTo(120, 380);
context.lineTo(150,490);
context.stroke();
 
ready
one polyline
context.beginPath();
context.moveTo(100.5, 100);
context.lineTo(120.5, 380);
context.lineTo(150.5,490);
context.stroke();
 
ready
one closed polyline
 
ready

Revisions

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