Skip to content

reimplement imageToByteArray in wasm#50

Draft
Julusian wants to merge 3 commits intomainfrom
feat/wasm
Draft

reimplement imageToByteArray in wasm#50
Julusian wants to merge 3 commits intomainfrom
feat/wasm

Conversation

@Julusian
Copy link
Copy Markdown
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