-
Notifications
You must be signed in to change notification settings - Fork 46
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
Switch to ericlagergren/decimal #1
Comments
Was there any reason to avoid using shopspring/decimal - I've used it a number of times and ended up rolling the start of an accounting library around it. Happy to collab |
As the oldest Go decimal library, shopspring/decimal is considered both the least correct and the least performant (in various corner cases). It also wasn't actively developed at the time when I evaluated cockroachdb/apd and ericlagergren/decimal, so it felt natural to skip it. Since I haven't done this evaluation nor benchmarking myself, I am prepared to be wrong. Here's the initial discussion where I raised this question: https://www.reddit.com/r/golang/comments/5zkzrq/apd_an_arbitraryprecision_decimal_package/dezc7sv/ |
There is a new v3 release of cockroachdb/apd. They have done some performance improvements. Where can I find the benchmarks mentioned in this issue? |
Okay, so cockroachdb/apd has a new 3.0.0 release with improved performance. Meanwhile, ericlagergren/decimal's latest release is still from Jan 2nd 2019. It's been a year and a half since I opened this issue, so it's safe to admit that the switch to ericlagergren/decimal can't and won't happen. Switched our apd usage from v2 to v3 in a4379f5. Looks like I've managed to lose the original benchmark file I used to compare the two packages. I will try to rebuild it to compare apd v2 and v3 at least, then link to the results here. If someone is curious enough to beat me to it, please go ahead! |
While we wait for currency-specific benchmarks, here's the pi_test from https://github.com/ericlagergren/decimal/tree/master/benchmarks: With apd v1:
With apd v3:
We can see a drastic reduction of allocations and memory usage, at the expense of CPU time at higher precisions. |
Made some benchmarks here: https://gist.github.com/bojanz/eda3c0d6fdc1db16aff0a964121686eb Copying the results here: Results for apd v2:
Results for apd v3:
I'll also retest once cockroachdb/apd#112 lands in an apd release. |
Benchmarks show ericlagergren/decimal to be noticeably faster than cockroachdb/apd, along with doing less allocations. We should try switching.
I'd like to get an answer to ericlagergren/decimal#153 before I merge this, since the current checks feel a bit repetitive.
EDIT: Answer received, waiting on maintainer fix.
The text was updated successfully, but these errors were encountered: