4 ms·
> HSLuv is already available for many languages btw, the JS port is not perf-optimized (it's a straight compilation from haxe to js). i hand-ported the C vers
by leeoniya 7y ago
> HSLuv is already available for many languages
btw, the JS port is not perf-optimized (it's a straight compilation from haxe to js).
i hand-ported the C version [1] locally that avoids heap-allocating any objects or arrays, which makes it about 40% faster. i'm hoping it gets to replace the "official" js port at some point, but i still need to run it through all the tests [2]. if anyone is interested in helping out with this (i'm tight on time right now), i'll publish it.
initial benchmark of 100k random RGB triplets completes in 100ms in Chrome 80 and 60ms in Firefox 73, on a pretty average Core i5-7500T @ 2.70GHz. 1M triplets is 680ms in chrome and 421ms in firefox. the official JS port gets 934ms in Chrome and 545ms in Firefox for 1M triplets.
For reference, a typical jpeg image contains < 300k unique colors.
[1] https://github.com/hsluv/hsluv-c https://github.com/hsluv/hsluv-c
[2] https://github.com/hsluv/hsluv-c/blob/master/tests/scripts/snapshot-rev4.json https://github.com/hsluv/hsluv-c/blob/master/tests/scripts/s...
- kuon 7y agoThis is great. I have to admit I usually "bake" my colors when using JS so I have not been hit by the performances, but if it can be done in a performent way, it can open new applications in the browser.
- tobr 7y agoNot sure how much help I would be, but if it’s any encouragement I would very much appreciate a “real” JS version. I looked at the JS version of HSLUV just the other week and was bummed that it was compiled from Haxe.
- throwaway3157 7y ago> was bummed that it was compiled from Haxe Why do you need a "real" JS version? Is it that you want to be able to read/edit from a human-source, rather than a Haxe-compiled source (which I assume is less legible)?
- lioeters 7y agoThat new JS-port of HSLuv C sounds great. Would love to see it published!
- microcolonel 7y agoAs far as testing goes, can't you just test all the colours? the space is pretty small. It should take something like less than 16 seconds in total per implementation, in each direction.