Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Chrome 131
Mac OS X 10.15.7
Desktop
one month ago
Test name Executions per second
di full 304538.6 Ops/sec
di half 307120.0 Ops/sec
pid full 300559.7 Ops/sec
pid half 279073.2 Ops/sec
HTML Preparation code:
AخA
 
1
<canvas id='master' width='100' height='100'></canvas>
2
<canvas id='clone' width='100' height='100'></canvas>
Script Preparation code:
x
 
var master = document.getElementById('master');
var masterctx = master.getContext('2d');
var clone = document.getElementById('master').getContext('2d');
masterctx.fillRect(0,0,50,50);
masterctx.fillStyle = "red";
masterctx.fillRect(50,50,100,100);
var img = masterctx.getImageData(0,0,100,100);
var half = masterctx.getImageData(25,0,50,100);
Tests:
  • di full

     
    clone.drawImage(master,0,0);
    clone.clearRect(0,0,100,100);
  • di half

     
    clone.drawImage(master,25,0,50,100,25,0,50,100);
    clone.clearRect(0,0,100,100);
  • pid full

     
    clone.putImageData(img,0,0);
    clone.clearRect(0,0,100,100);
  • pid half

     
    clone.putImageData(half,25,0);
    clone.clearRect(0,0,100,100);