kotlin-multiplatform-bignum
kotlin-multiplatform-bignum copied to clipboard
[PERF] longValue(exactRequired = true) is very slow
Describe the bug
No problem with the returned value, but the cost of using exactRequired = true
is order of magnitude more costly than using exactRequired = false
.
To Reproduce
I was working on some load tests on our mathematical library, so a lot of calls were involved (BD creation, addition, multiplication, ...). In my case the BigDecimal was always rounded just before the call to longValue(exactRequired = true)
.
With the exactRequired = true
this test was taking 7.5 minutes, when I just changed the boolean to false, it took 1.4 seconds.
Sorry that's maybe not clear to reproduce, but I believe any attempts should show a similarly high impact.
In my case, I'd prefer to use exactRequired = true
as I'm actually expecting an exact value, but the performance wasn't explicit.
Platform
- Reproduced on JVM (maybe other platforms impacted)