Batching Line Drawing Calls

JavaScript performance comparison

Test case created by Boris

Preparation code

<canvas id="c" width="640" height="480"></canvas>
<script>
  var canvas = document.getElementById('c');
  var context = canvas.getContext('2d');
  context.strokeStyle = 'black';
</script>
      
<script>
Benchmark.prototype.setup = function() {
  context.clearRect(0, 0, canvas.width, canvas.height);

};
</script>

Preparation code output

<canvas id="c" width="640" height="480"></canvas>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
multiple lines
context.beginPath();
context.moveTo(100, 100);
context.lineTo(100, 380);
context.stroke();

context.beginPath();
context.moveTo(100, 380);
context.lineTo(540, 380);
context.stroke();

context.beginPath();
context.moveTo(540, 380);
context.lineTo(540, 100);
context.stroke();

context.beginPath();
context.moveTo(540, 100);
context.lineTo(100, 100);
context.stroke();
pending…
one polyline
context.beginPath();
context.moveTo(100, 100);
context.lineTo(100, 380);
context.lineTo(540, 380);
context.lineTo(540, 100);
context.lineTo(100, 100);
context.stroke();
pending…
one closed polyline
context.beginPath();
context.moveTo(100, 100);
context.lineTo(100, 380);
context.lineTo(540, 380);
context.lineTo(540, 100);
context.closePath();
context.stroke();
pending…

Compare results of other browsers

Revisions

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

0 Comments