Similar PR than previous one but with focus on the BigInteger.
@Test
fun perfTest() {
val bd = BigInteger.parseString("123")
val duration = measureTime {
repeat(1_000_000) { bd.numberOfDecimalDigits() }
}
println("Duration: $duration")
}
Result (best of 3 runs)
platform
Before
After
Time reduction
iosSimulator
4.60s
0.62s
reduction of 86%
JVM
219ms
75.2ms
reduction of 66%
macosArm64
4.91s
0.67ms
reduction of 86%
All benchmark data
All runs are done on the same MacBook Pro M3 with 36GB RAM.
Before
ios 4.83, 4.60, 4.67
jvm 234ms, 219ms, 241ms
mac 4.92, 4.91, 4.98
After
ios 622ms, 617ms, 619ms
jvm 11.6ms, 9.8ms, 11.4ms
mac 673ms, 666ms, 666ms
Just a side note, I took a relatively short value for the benchmark, I guess performances may vary with length (like the previous implementation). I only run one more test on JVM with "123456789012345678901234567890123456", before 232ms, after 54ms, so I guess we're still in a better place.
Similar PR than previous one but with focus on the BigInteger.
Result (best of 3 runs)
All benchmark data
All runs are done on the same MacBook Pro M3 with 36GB RAM.
Before
After
Just a side note, I took a relatively short value for the benchmark, I guess performances may vary with length (like the previous implementation). I only run one more test on JVM with "123456789012345678901234567890123456", before 232ms, after 54ms, so I guess we're still in a better place.