canvas-path

JavaScript performance comparison

Test case created by Ilmari

Preparation code

<script>
  var c = document.createElement('canvas');
  c.width = c.height = 256;
  var ctx = c.getContext('2d');
</script>
    

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
ten
ctx.beginPath();
var x = 128,
    y = 128;
ctx.moveTo(x, y);

var n = 10;
for (var i = 0; i < n; i++) {
 var nx = 128 + Math.cos(i / n * Math.PI * 2);
 var ny = 128 + Math.sin(i / n * Math.PI * 2);
 ctx.bezierCurveTo(x, y, nx, ny, nx, ny);
 x = nx;
 y = ny;
}
ctx.fill();
pending…
hundred
ctx.beginPath();
var x = 128,
    y = 128;
ctx.moveTo(x, y);

var n = 100;
for (var i = 0; i < n; i++) {
 var nx = 128 + Math.cos(i / n * Math.PI * 2);
 var ny = 128 + Math.sin(i / n * Math.PI * 2);
 ctx.bezierCurveTo(x, y, nx, ny, nx, ny);
 x = nx;
 y = ny;
}
ctx.fill();
pending…
thousand
ctx.beginPath();
var x = 128,
    y = 128;
ctx.moveTo(x, y);

var n = 1000;
for (var i = 0; i < n; i++) {
 var nx = 128 + Math.cos(i / n * Math.PI * 2);
 var ny = 128 + Math.sin(i / n * Math.PI * 2);
 ctx.bezierCurveTo(x, y, nx, ny, nx, ny);
 x = nx;
 y = ny;
}
ctx.fill();
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