Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
drawing pixels: putImageData vs fillRect
(version: 1)
Comparing performance of:
putImageData vs fillRect
Created:
one year ago
by:
Guest
Jump to the latest result
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); } }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
putImageData
fillRect
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:136.0) Gecko/20100101 Firefox/136.0
Browser/OS:
Firefox 136 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
putImageData
361.3 Ops/sec
fillRect
1.2 Ops/sec
Related benchmarks:
drawimage vs putimagedata 2
drawimage vs putimagedata 3
drawimage vs putimagedata 3b
PutImageData vs DrawImage (big canvases)
Canvas vs img
putImageData vs drawImage methods
MAGENTA PutImageData vs fillRect
PutImageData vs DrawImage v3
drawing pixels: putImageData vs fillRect v2
Comments
Confirm delete:
Do you really want to delete benchmark?