Batching Line Drawing Calls (v21)

Revision 21 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
Lines
context.beginPath();
context.moveTo(Math.round(100.052484), Math.round(100.56121546));
context.lineTo(Math.round(150.32123), Math.round(100.12035468));
context.lineTo(Math.round(150.6789715), Math.round(150.64597102));
context.lineTo(Math.round(100.68798456), Math.round(150.6481321));
context.lineTo(Math.round(100.548653), Math.round(100.2315487897));
context.stroke();
ready
Dots
context.beginPath();
context.arc(Math.round(100.052484), Math.round(100.56121546), 1, 0, 2*Math.PI);
context.fill();
context.arc(Math.round(150.32123), Math.round(100.12035468), 1, 0, 2*Math.PI);
context.fill();
context.arc(Math.round(150.6789715), Math.round(150.64597102), 1, 0, 2*Math.PI);
context.fill();
context.arc(Math.round(100.68798456), Math.round(150.6481321), 1, 0, 2*Math.PI);
context.fill();
ready

Revisions

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