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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reimplement imageToByteArray in wasm #50

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

reimplement imageToByteArray in wasm #50

wants to merge 3 commits into from

Conversation

Julusian
Copy link
Owner

@Julusian Julusian commented Jul 2, 2022

This library is doing some bitmap manipulation to cater to the different flip/rotation required for some models, and the colour space both over the wire, and being provided by user code.

Doing this in javascript is not particularly efficient.
This re-implements that logic in rust, compiled to wasm. By doing this, we get a ~50% speed boost on this block of code.
On my i7 laptop, it improves to 40ms from 90ms for 1000 images.
On a pi zero w2, it improves to 420ms from 880ms for 1000 images.
This improvement on the pi makes the extra complexity of this feel worthwhile. This is a rather synthetic test, but even doing kust a full panel draw of an xl from the pi saves ~15ms (I adjusted the test to verify).

For compatability, I think we should support both wasm and native js for this code. If for some reason wasm is unavailable (perhaps running in a browser and the wasm file has not been provided), then we can fallback to javascript. The performance improvement is not proven to be significant enough to justify requiring wasm.

I dont expect this to result in more than a couple of percent improvement, I shall do some more testing once this is closer to being usable

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.

1 participant