papandreou / subset-font

Create a subset of a TrueType/OpenType/WOFF/WOFF2 font using the wasm build of harfbuzz/hb-subset
BSD 3-Clause "New" or "Revised" License
85 stars 6 forks source link

add a benchmark file #11

Closed alsotang closed 3 months ago

alsotang commented 3 years ago

But seems there is no space to improve. I try to do some memory copy related optimize but nothing changed

papandreou commented 3 years ago

Hmm, yeah, there's mainly "glue code" in here, so I think we'd be tracking the performance of harfbuzzjs more than anything.

papandreou commented 3 years ago

All the wasm gymnastics consists of sync operations (which is why I added the p-limit for predictability), but maybe we can use web workers to parallelize. We might even use this trick to share the heap: https://stackoverflow.com/questions/59818702/can-you-share-webassembly-memory-between-web-workers

For more specific use cases where you create subsets of the same font over and over again you could also add the original TTF to the heap only once -- but supporting that would lead to a more complex api.

alsotang commented 3 years ago

According to my current opinion, the memory optimization will not have a significant impact on the performance of this library, and may at most improve a 20% in some scenarios. So it's better to keep it simple.