Test name | Executions per second |
---|---|
img | 19934520.0 Ops/sec |
canvas | 19775930.0 Ops/sec |
bitmap | 19971804.0 Ops/sec |
var canvas = document.createElement('canvas')
var context = canvas.getContext('2d')
var bitmap
var img = new Image()
img.onload = async () => {
canvas.width = img.width
canvas.height = img.height
context.drawImage(img, 0, 0)
bitmap = await createImageBitmap(img)
}
img.src = 'https://neurostof.nl/ns/letters.jpg'
var c = document.createElement('canvas').getContext('2d')
// bitmap && c.drawImage(img, 250, 250, 250, 250, 0, 0, 1000, 1000)
// bitmap && c.drawImage(canvas, 250, 250, 250, 250, 0, 0, 1000, 1000)
// bitmap && c.drawImage(bitmap, 250, 250, 250, 250, 0, 0, 1000, 1000)
bitmap && c.drawImage(img, 250, 250, 250, 250, 0, 0, 1000, 1000)
bitmap && c.drawImage(canvas, 250, 250, 250, 250, 0, 0, 1000, 1000)
bitmap && c.drawImage(bitmap, 250, 250, 250, 250, 0, 0, 1000, 1000)