3 ms·
When trying to make my editor, KeenWrite[0], render TeX in real time using JMathTeX[1], I used initially used JFreeSVG[2] to generate SVG images (not rasterize
by thangalin 4y ago
When trying to make my editor, KeenWrite[0], render TeX in real time using JMathTeX[1], I used initially used JFreeSVG[2] to generate SVG images (not rasterize them). After running the code through async-profiler[3], it turned out that JFreeSVG was using Java's NumberFormat to convert double values to strings.
Comparative benchmarks when generating 1,000,000 SVGs from TeX expressions, 1 run each, no warm-up:
* NumberFormat: 778060 milliseconds (~13 minutes)
* RyuDouble: 421160 milliseconds (~7 minutes)
Eventually I replaced JMathTeX with my NTS fork[4] and replaced the JFreeSVG library with a custom class to create SVG document strings[5].
Going from non-real-time TeX to real-time TeX rendering was worth it.
[0]: https://github.com/DaveJarvis/keenwrite https://github.com/DaveJarvis/keenwrite
[1]: https://jmathtex.sourceforge.net/ https://jmathtex.sourceforge.net/
[2]: https://github.com/jfree/jfreesvg/ https://github.com/jfree/jfreesvg/
[3]: https://github.com/async-profiler/async-profiler https://github.com/async-profiler/async-profiler
[4]: https://github.com/DaveJarvis/KeenType https://github.com/DaveJarvis/KeenType
[5]: https://github.com/DaveJarvis/KeenType/blob/main/svg/src/main/java/com/whitemagicsoftware/keentype/svg/KtSvgFormatWriter.java https://github.com/DaveJarvis/KeenType/blob/main/svg/src/mai...
[6]: https://github.com/jfree/jfreesvg/pull/30 https://github.com/jfree/jfreesvg/pull/30 (bonus link)
P.S.
Eventually, I replaced the Ryu Algorithm with an even faster (and simpler) double-to-string conversion:
https://github.com/DaveJarvis/KeenType/blob/main/tex/src/main/java/com/whitemagicsoftware/keentype/render/KtFastDouble.java https://github.com/DaveJarvis/KeenType/blob/main/tex/src/mai...
- phkahler 4y ago>> Going from non-real-time TeX to real-time TeX rendering was worth it. That is one of those jumps that completely changes the nature of an app. IMHO on today's computers almost everything should feel like real time. Highly interactive at the very least.