Canvas path performance

JavaScript performance comparison

Revision 2 of this test case created by

Preparation code

<canvas id="canvas" width="600" height="600"></canvas>
      
<script>
Benchmark.prototype.setup = function() {
  var canvas = document.getElementById('canvas');
  var ctx = canvas.getContext('2d');
  ctx.strokeStyle = "red";
  var count = 0;

};
</script>

Preparation code output

<canvas id="canvas" width="600" height="600"></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
Fully batched
ctx.beginPath();
for (var i=0;i<1500;i++){
    ctx.moveTo(0, i);
    ctx.lineTo(i, 0);
}
ctx.stroke();
ctx.closePath();
pending…
Chunked
ctx.beginPath();
for (var i=0;i<1500;i++){
    if (count%200===0){
        ctx.stroke();
        ctx.closePath();
        ctx.beginPath();
    }
    ctx.moveTo(0, i);
    ctx.lineTo(i, 0);
    count++;
}
ctx.stroke();
ctx.closePath();
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