Context2D self-drawImage (v5)

Revision 5 of this benchmark created on


Setup

var canvas1 = document.createElement('canvas')
;
var canvas2 = document.createElement('canvas')
;
var canvas3 = document.createElement('canvas')
;
for (var canvas of [canvas1, canvas2, canvas3]) {
	canvas.width = 1024;
	canvas.height = 1024;
}

const opts = {
	alpha: false,
};
var cx1 = canvas1.getContext('2d', opts);
var cx2 = canvas2.getContext('2d', opts);
var cx3 = canvas3.getContext('2d', opts);

for (var cx of [cx1, cx2, cx3]) {
	cx.globalCompositeOperation = 'copy';
}

// Fill them with random contents to prevent
// framebuffer compression
const imgdata = new ImageData(canvas1.width, canvas2.height);
for (let i = 0; i < imgdata.data.length; ++i) {
	imgdata.data[i] = Math.random() * 256;
}

for (var cx of [cx1, cx2]) {
	cx.putImageData(imgdata, 0, 0);
}

Test runner

Ready to run.

Testing in
TestOps/sec
drawImage(self)
cx1.drawImage(canvas1, 1, 1);

cx3.drawImage(canvas1, 0, 0);
ready
drawImage(other)
cx1.drawImage(canvas2, 1, 1);

cx3.drawImage(canvas1, 0, 0);
ready
drawImage(self) by ping-pong
cx2.drawImage(canvas1, 0, 0);
cx1.drawImage(canvas2, 1, 1);

cx3.drawImage(canvas1, 0, 0);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.