Wakamai-Fondue / wakamai-fondue-engine

The engine that powers Wakamai Fondue
Apache License 2.0
46 stars 9 forks source link

Add memoization to cache (expensive) lookups/calculations #11

Closed RoelN closed 3 years ago

pascalw commented 4 years ago

I did some very basic benchmarking and nothing really jumps out needing any memoization or other perf improvements:

ϟ node test/bench.js
get() → 19.442801ms
get('GSUB') → 0.584874ms
get format → 0.10351ms
get isColor → 0.063862ms
get isVariable → 0.019628ms
get hasFeatures → 0.647321ms
get hasLanguages → 0.454317ms
get languageSystems → 0.176993ms
get features → 0.623004ms
get tables → 0.00693ms
get variable → 0.008594ms
get css → 6.729ms
get summary → 2.877824ms
get colorFormats → 0.008769ms
get cssString → 5.372526ms
get customText → 0.182774ms
get supportedCharacters → 0.911318ms

These are all measurements of operations on a fresh Fondue instance, excluding the loadFondue() call itself.

Granted this is on a high-end machine, running in Node. A lowend machine running WF in the browser might be a bit slower, but it doesn't seem worth it yet to optimize anything.

@RoelN WDYT?

RoelN commented 3 years ago

@pascalw Interesting, thanks! With which font(s) did you test? It would be interesting to see a relatively complex font (large charset, many OT layout features, variable axes) as that might give different results than a simple font.

That said, with these minuscule benchmark times, this has "premature optimization" written all over it. Let's close this issue and open a new one when we actually run into slowdown!

pascalw commented 3 years ago

This is data from SourceCodePro-Regular.