Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

spread parameter is slow #105

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

spread parameter is slow #105

wants to merge 1 commit into from

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

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.

None yet

1 participant