Skip to content

Conversation

@kawanet
Copy link

@kawanet kawanet commented Dec 11, 2021

The small patch draws pixels up to x27 times faster.

The current code draws a pixel with spread parameters drawPixel(output, pos, ...color).

The magic ... looks cool but runs slower compared to traditional coding styles still.

code x 100,000,000 times Chrome 96 Safari 15 Firefox 95 result
drawPixel(output, pos, ...color) 1,333 ms 4,289 ms 5,230 ms slow 👎
drawPixel(output, pos, color[0], color[1], color[2]) 246 ms 1,552 ms 492 ms fast 👍
drawColorFn(output, color)(pos) 144 ms 1,154 ms 190 ms faster 👍 👍

The benchmark above was tested on MacBook M1 Apple Silicon.
Try it: https://gist.github.com/kawanet/4676a1804bb463ea558017b063d4c286

@mourner mourner closed this in 085205c Jun 26, 2024
@mourner
Copy link
Member

mourner commented Jun 26, 2024

Apologies for not noticing this PR at the time. 🙏 Closing in favor of a slightly simpler optimization which is fast enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants