composite-vs-clip

Benchmark created by Simon on


Preparation HTML

<canvas id="canvas1" width="500" height="500"></canvas>
<script>
  var can = document.getElementById('canvas1');
  var ctx = can.getContext('2d');
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
clip

ctx.beginPath();
ctx.arc(90, 90, 50, 0, Math.PI*2 )
ctx.clip();

ctx.fillStyle = 'rgba(255,255,0,.5)';
ctx.fillRect(30,30,200,200);
ready
composite
ctx.beginPath();
ctx.arc(90, 90, 50, 0, Math.PI*2 )
ctx.fill();

ctx.globalCompositeOperation = "source-in"

ctx.fillStyle = 'rgba(255,255,0,.5)';
ctx.fillRect(30,30,200,200);
ready

Revisions

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