Class PhiloxGenerationPerformance
- java.lang.Object
-
- org.apache.commons.rng.examples.jmh.core.AbstractBenchmark
-
- org.apache.commons.rng.examples.jmh.core.PhiloxGenerationPerformance
-
public class PhiloxGenerationPerformance extends AbstractBenchmark
Executes benchmark to compare the speed of generation of random numbers from the various Philox providers.Performance Notes
Some improvements to performance are observed on JDK 8 for the inline and zero variations of the 32-bit generator. On higher JDKs the performance of the original implementation is consistently the best and the modified variants are either the same speed but can be significantly slower. This typically occurs for the inline variant which may not be efficiently targeted by the JVM optimisations. The variations are left for future development.
The 64-bit generator can be made significantly faster if it uses the 64-bit multiplication methods available in the
Mathclass (see RNG-188).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPhiloxGenerationPerformance.SourcesThe benchmark state (retrieve the various "RandomSource"s).
-
Constructor Summary
Constructors Constructor Description PhiloxGenerationPerformance()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intbaselineInt()Baseline for a JMH method call returning anint.longbaselineLong()Baseline for a JMH method call returning along.intnextInt(PhiloxGenerationPerformance.Sources sources)Exercise theUniformRandomProvider.nextInt()method.longnextLong(PhiloxGenerationPerformance.Sources sources)Exercise theUniformRandomProvider.nextLong()method.
-
-
-
Constructor Detail
-
PhiloxGenerationPerformance
public PhiloxGenerationPerformance()
-
-
Method Detail
-
baselineInt
public int baselineInt()
Baseline for a JMH method call returning anint.- Returns:
- the value
-
baselineLong
public long baselineLong()
Baseline for a JMH method call returning along.- Returns:
- the value
-
nextInt
public int nextInt(PhiloxGenerationPerformance.Sources sources)
Exercise theUniformRandomProvider.nextInt()method.- Parameters:
sources- Source of randomness.- Returns:
- the int
-
nextLong
public long nextLong(PhiloxGenerationPerformance.Sources sources)
Exercise theUniformRandomProvider.nextLong()method.- Parameters:
sources- Source of randomness.- Returns:
- the long
-
-