RFR: 8356993: ArrayDeque should use Arrays.fill() instead of for() loops [v2]
Archie Cobbs
acobbs at openjdk.org
Thu May 15 21:04:40 UTC 2025
On Thu, 15 May 2025 18:33:22 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:
> Here are many [exmaples](https://github.com/openjdk/jmh/tree/master/jmh-samples/src/main/java/org/openjdk/jmh/samples) on how to correctly use JMH.
>
> A [blackhole](https://github.com/openjdk/jmh/blob/master/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_09_Blackholes.java) prevents the compiler to optimize away your code.
Thanks for the tip. FWIW after doing that the numbers came out about the same - which is not surprising given that `Arrays.fill()` is just the same `for()` loop...
#2 - After adding Blackhole
jdk-25+22-94-g0318e49500e (master):
Benchmark Mode Cnt Score Error Units
ArrayDeque.ClearBenchmarkTestJMH.fillAndClear thrpt 50 35.663 ± 0.163 ops/s
jdk-25+22-97-g9f0c5fe1f90 (JDK-8356993):
Benchmark Mode Cnt Score Error Units
ArrayDeque.ClearBenchmarkTestJMH.fillAndClear thrpt 50 35.112 ± 0.501 ops/s
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25237#discussion_r2091954179
More information about the core-libs-dev
mailing list