RFR: 7903367: JMH: Add JMHSample_39_MemoryAccess [v2]
Vsevolod Tolstopyatov
duke at openjdk.org
Wed Oct 19 14:47:31 UTC 2022
On Wed, 19 Oct 2022 14:40:25 GMT, Vsevolod Tolstopyatov <duke at openjdk.org> wrote:
>> Michael Mirwaldt has updated the pull request incrementally with one additional commit since the last revision:
>>
>> improved by proposals from first review
>
> jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_39_MemoryAccess.java line 65:
>
>> 63: * Benchmark Mode Cnt Score Error Units
>> 64: * JMHSample_39_MemoryAccess.sumArray avgt 25 50.393 ± 0.407 ms/op
>> 65: * JMHSample_39_MemoryAccess.sumArrayList avgt 25 299.868 ± 1.591 ms/op
>
> It maybe can be even more educational if the benchmarks will expose how *unstable* such measurements are.
>
> Having a third benchmark with the same `ArrayList` with the same `Integer` objects, but **shuffled** yields a completely different result. The educational hint here is that it can be GC who can do the actual shuffle
My machine, `N = 20_000_000`:
Benchmark Mode Cnt Score Error Units
MemoryAccess.sumArray avgt 5 7.296 ± 0.276 ms/op
MemoryAccess.sumArrayList avgt 5 45.077 ± 1.787 ms/op
MemoryAccess.sumArrayListShuffled avgt 5 544.628 ± 64.948 ms/op
-------------
PR: https://git.openjdk.org/jmh/pull/85
More information about the jmh-dev
mailing list