Long.bitCount micro-optimization
Brian Burkhalter
brian.burkhalter at oracle.com
Tue May 9 01:01:19 UTC 2017
Thanks for running the numbers.
On May 8, 2017, at 5:42 PM, Isaac Levy <isaac.r.levy at gmail.com> wrote:
> bitCountInt avgt 10 44550.630 ± 2670.294 ns/op
[41880, 47221]
> bitCountIntNew avgt 10 33904.058 ± 1108.438 ns/op
[32796, 35012]
> bitCountLong avgt 10 58638.138 ± 3736.014 ns/op
[54902, 62374]
> bitCountLongNew avgt 10 38700.601 ± 526.648 ns/op
[38174, 39227]
So the ranges don’t overlap which is important.
> JDK 1.8.0_131, 2.3ghz Core i7, each run counting numbers 0 to 2^14
Thing is one needs to run the benchmark on a variety of hardware. I went through a lot of this sort of thing myself when evaluating among other things for example the crossover thresholds for the Karatsuba and Toom-Cook multiplication algorithms in BigInteger multiplication. There was a lot of variation.
Thanks,
Brian
More information about the core-libs-dev
mailing list