Test name | Executions per second |
---|---|
Image | 21857364.0 Ops/sec |
ImageBitmap | 22161024.0 Ops/sec |
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';
if (doneLoading)
ctx.drawImage(img,0,0);
if (doneLoading)
ctx2.drawImage(imageBitmap,0,0);