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
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