Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36
Chrome 97
Mac OS X 10.15.7
Desktop
2 years ago
Test name Executions per second
Image 261380.7 Ops/sec
ImageBitmap 213543.1 Ops/sec
Script Preparation code:
x
 
var img = new Image();
var imageBitmap;
var doneLoading = false;
let canvas = document.createElement('canvas');
canvas.width = 640;
canvas.height = 480;
let canvas2 = document.createElement('canvas');
canvas2.width = 640;
canvas2.height = 480;
var ctx = canvas.getContext('2d');
var ctx2 = canvas2.getContext('2d');
img.addEventListener('load', function() {
  Promise.all([
    createImageBitmap(img)
  ]).then(function(images) {
  imageBitmap = images[0];
  doneLoading = true;
}, false);
});
img.src = 'https://media.discordapp.net/attachments/447410261289205781/574359442913492992/unknown.png';
Tests:
  • Image

     
    if (doneLoading)
    ctx.drawImage(img,0,0);
  • ImageBitmap

     
    if (doneLoading)
    ctx2.drawImage(imageBitmap,0,0);