Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Canvas Pixel vs Fill rect
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Browser:
Chrome 120
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
1*1 fillRect/concat
0.8 Ops/sec
Image Data
1.1 Ops/sec
HTML Preparation code:
<canvas id="c" width="1000" height="500"></canvas>
Script Preparation code:
$c = document.getElementById('c'); $ctx = $c.getContext('2d'); $ctx.clearRect(0, 0, 10000, 500); $px = $ctx.createImageData(1000, 500); $pxls = []; for (var i=0; i<500000; ++i) $pxls.push({ x: Math.random() * 1000 << 0, y: Math.random() * 500 << 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:
1*1 fillRect/concat
for (var i=1000;i--;){ for(var j=500;j--;){ var px = $pxls[i*j] $ctx.fillStyle = 'rgba(' + px.r + ',' + px.g + ',' + px.b + ',' + (px.a / 255) + ')'; $ctx.fillRect(px.x, px.y, 1, 1); } }
Image Data
for (var i=0; i<500000; ++i){ var px=$pxls[i], d=$px.data[i]; d[0] = px.r; d[1] = px.g; d[2] = px.b; d[3] = px.a; } $ctx.putImageData($px, 1000,500);