-
-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace NumberFormat with Ryu algorithm #30
Conversation
Interesting results as well as problem approach. I don't think I had seen Ryu yet, though I remember seeing a less complete library along those lines a few years ago and a few years ago I "grew my own" solution to some of the problems addressed by a few of those methods (I was on the verge of publishing these as part of a small math library last month). I hope to find time to review this in more depth later, as my specialty in graduate school was Numerical Analysis and so I have a real passion for evaluating and comparing the efficiency and precision of libraries that deal with numeric conversions of all types. As the Ryu code was pulled in directly, probably it doesn't break any rules, but I'm too tired to look those up right now. My recollection is that the goal of each of these JFree projects is to not have outside dependencies, but that seems to be met (and I could be wrong). The style changes are a mixed bag in terms of my own personal preferences as well as what may be established coding conventions within the JFree family (the overall code base is becoming much more consistent lately). Regardless of what is decided by the project organizers, I appreciate the time and commitment that you put into this, and there are several categories of lessons that are valuable and may help in other contexts as well. |
Updates correct geometry precision error and improper truncation of return value. |
Nice work, thanks! |
Changes:
NumberFormat
for both geometry and transform to use Ryu algorithm. Move constructor member variable initialization to declaration member variable initialization to avoid minor variable reassignment duplication. Collapses imports (the IDE did this automatically, sorry; although, modern IDEs handle import management very well these days). Set default value of geometryDP (2) and transformDP (6). Sprinklefinal
modifiers for method parameters.ROUND_EVEN
. Could be a clean up item to remove the enum and update the Ryu algorithm accordingly.NumberFormat
class, so this class can probably be deleted.Comparative benchmarks when generating 1,000,000 SVGs from TeX expressions, 1 run each, no warm-up:
Here's a before and after profiling snapshot of the application's hot spot:
And after:
Before:
And after:
Further optimizations may be possible, such as removing the scientific notation logic from the Ryu algorithm provided it isn't used by the SVG standard.