Previous benchmark was measuring initialization of thread pools and their shutdown, not really measuring performance of Random.nextInt() shared Random instance vs ThreadLocalRandom.current() Example when run with 8 threads Benchmark Mode Cnt Score Error Units ThreadLocalRandomBenchMarker.randomValuesUsingRandom thrpt 20 9.597 ± 0.475 ops/us ThreadLocalRandomBenchMarker.randomValuesUsingThreadLocalRandom thrpt 20 2195.178 ± 109.579 ops/us |
||
---|---|---|
.. | ||
main/java/com/baeldung | ||
test/java/com/baeldung |