I'm trying to figure out why a benchmark of Java's BigInteger multiplication is consistently 3x faster than using an instance from BigInteger.java source code copied over to my project. Using jmh to run the benchmark. Here is an example output, note that addition runs about the same.
Benchmark Mode Cnt Score Error Units
BenchmarkTest.javaBigInteger_add thrpt 5 856062.338 � 34040.923 ops/s
BenchmarkTest.sourceBigInteger_add thrpt 5 842421.746 � 39630.112 ops/s
BenchmarkTest.javaBigInteger_multiply thrpt 5 525649.635 � 15271.083 ops/s
BenchmarkTest.sourceBigInteger_multiply thrpt 5 133944.766 � 1832.857 ops/s
Reason I am doing this is in an attempt to port part of this to Kotlin I noticed the benchmarks were a bit slower. To see if it was related to Kotlin I removed that from the picture and did everything in pure java with the exact same results. Why would this benchmark vary so much if the source code/algorithms are exactly the same?
Project with this code: https://github.com/asheragy/BigInteger-Benchmark