Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Setting Canvas Pixel
(version: 0)
Comparing performance of:
fillRect/concat vs fillRect/join
Created:
8 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<canvas id="c" width="800" height="800"></canvas>
Script Preparation code:
$c = document.getElementById('c'); $ctx = $c.getContext('2d'); $ctx.clearRect(0, 0, 800, 800); $px = $ctx.createImageData(1, 1); $pxls = []; for (var i=0; i<10000; ++i) $pxls.push({ x: Math.random() * 800 << 0, y: Math.random() * 800 << 0, r: 255, g: 0, b: 0, a: 0 }); $i = 0;
Tests:
fillRect/concat
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); }
fillRect/join
for (var i=500;i--;){ var px = $pxls[$i++ % 10000]; $ctx.fillStyle = 'rgba(' + [px.r,px.g,px.b,px.a/255].join() + ')'; $ctx.fillRect(px.x, px.y, 1, 1); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
fillRect/concat
fillRect/join
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36
Browser/OS:
Chrome 136 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
fillRect/concat
3310.6 Ops/sec
fillRect/join
2984.7 Ops/sec
Related benchmarks:
Setting Canvas Pixel
Setting Canvas Pixel with lots of iterations - looking more at get/put
Setting Canvas Pixel With Same Color
Setting Canvas Pixel with Template String
Comments
Confirm delete:
Do you really want to delete benchmark?