Thanks for the suggestion

On 14/09/2020 22:13, Thangalin wrote:
Hey list,

JFreeSVG uses DecimalFormat to convert double values to strings. Ryū
is a fast double-to-string conversion algorithm that has a simple
drop-in replacement. The performance gains were substantial.

Batik also uses DecimalFormat for the exact same reason and thus would
also benefit significantly from an upgrade. Specifically:

https://github.com/apache/xmlgraphics-batik/blob/trunk/batik-svggen/src/main/java/org/apache/batik/svggen/SVGGeneratorContext.java#L426

Using Java's formatter:

--- 3089912936 ns (10.04%), 309 samples
   [ 0] jdk.internal.math.FloatingDecimal$BinaryToASCIIBuffer.dtoa
   [ 1] jdk.internal.math.FloatingDecimal.getBinaryToASCIIConverter
   [ 2] jdk.internal.math.FloatingDecimal.getBinaryToASCIIConverter
   [ 3] java.text.DigitList.set
   [ 4] java.text.DecimalFormat.doubleSubformat
   [ 5] java.text.DecimalFormat.format
   [ 6] java.text.DecimalFormat.format
   [ 7] java.text.NumberFormat.format
   [ 8] org.jfree.svg.SVGGraphics2D.geomDP

Using Ryū more than doubles throughput:

--- 7429730977 ns (23.92%), 743 samples
   [ 0] org.jfree.svg.util.RyuDouble.doubleToString
   [ 1] org.jfree.svg.SVGGraphics2D.geomDP

A Java implementation is available online:

https://github.com/ulfjack/ryu/blob/master/src/main/java/info/adams/ryu/RyuDouble.java

Attached is a variation that allows control over precision.

Generating these strings is performed everywhere throughout the svggen
code, so tweaking this part of the code base should see significant
gains.

Cheers everybody!

---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: general-h...@xmlgraphics.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: general-h...@xmlgraphics.apache.org

Reply via email to