Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Large Canvas Performance Test
Comparing performance of: fillRect vs putImage on large canvas
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.6668.70 Mobile Safari/537.36
Browser:
Chrome Mobile 129
Operating system:
Android
Device Platform:
Mobile
Date tested:
one year ago
Test name
Executions per second
fillRect
434.3 Ops/sec
putImage
28.5 Ops/sec
HTML Preparation code:
<canvas id="c" width="5000" height="5000"></canvas>
Script Preparation code:
$c = document.getElementById('c'); $ctx = $c.getContext('2d'); $ctx.clearRect(0, 0, 5000, 5000); $px = $ctx.createImageData(1, 1); $pxls = []; for (var i=0; i<10000; ++i) $pxls.push({ x: Math.random() * 5000 << 0, y: Math.random() * 5000 << 0, r: Math.random() * 255 << 0, g: Math.random() * 255 << 0, b: Math.random() * 255 << 0, a: Math.random() * 128 << 0 + 128 }); $i = 0;
Tests:
fillRect
for (var i=500;i--;){ var px = $pxls[$i++ % 10000]; $ctx.fillStyle = 'rgba(' + px.r + ',' + px.g + ',' + px.b + ',' + (px.a / 255) + ')'; $ctx.fillRect(px.x, px.y, 1, 1); }
putImage
var image = $ctx.createImageData($c.width, $c.height); for (var i=500;i--;){ var px=$pxls[$i++ % 10000], d=$px.data; var _pidx = i * 4; image.data[_pidx] = px.r; image.data[_pidx+1] = px.g; image.data[_pidx+2] = px.b; image.data[_pidx+3] = px.a; } $ctx.putImageData(image, 0, 0);