Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36 OPR/70.0.3728.189
Opera 70
Windows
Desktop
4 years ago
Test name Executions per second
di full 86676.4 Ops/sec
di half 88346.9 Ops/sec
pid full 109581.2 Ops/sec
pid half 92406.3 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);