Batching Line Drawing Calls (v4)

Revision 4 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';
</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(540, 380);
context.stroke();

context.beginPath();
context.moveTo(100, 380);
context.lineTo(540, 100 , 150 , 200);
context.stroke();
 
ready
one polyline
context.beginPath();
context.moveTo(100, 100);
context.lineTo(540, 380);
context.moveTo(100, 380);
context.lineTo(540, 100);
context.stroke();
ready

Revisions

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