Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
drawing pixels: putImageData vs fillRect
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:144.0) Gecko/20100101 Firefox/144.0
Browser:
Firefox 144
Operating system:
Linux
Device Platform:
Desktop
Date tested:
3 months ago
Test name
Executions per second
putImageData
2051.9 Ops/sec
fillRect
9.5 Ops/sec
HTML Preparation code:
<canvas id='aa' width='320' height='180'></canvas> <canvas id='bb' width='320' height='180'></canvas>
Script Preparation code:
var aa = document.getElementById('aa').getContext('2d'); var bb = document.getElementById('bb').getContext('2d'); var pixels = new Uint8ClampedArray(320 * 180 * 4); var imgdata = new ImageData(pixels, 320, 180);
Tests:
putImageData
for (var y = 0; y < 180; y++) { for (var x = 0; x < 320; x++) { var i = y * 180 * 4 + x * 4; pixels[i + 0] = Math.floor(Math.random() * 256); pixels[i + 1] = Math.floor(Math.random() * 256); pixels[i + 2] = Math.floor(Math.random() * 256); pixels[i + 3] = 255; } } aa.putImageData(imgdata, 0, 0);
fillRect
for (var y = 0; y < 180; y++) { for (var x = 0; x < 320; x++) { var r = Math.floor(Math.random() * 256); var g = Math.floor(Math.random() * 256); var b = Math.floor(Math.random() * 256); bb.fillStyle = `rgb(${r},${g},${b})`; bb.fillRect(x, y, 1, 1); } }