This is an automated email from the ASF dual-hosted git repository. aherbert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-rng.git
commit f5e1e0cb5310cff34308fd6a8574ff977cc443be Author: aherbert <aherb...@apache.org> AuthorDate: Tue Apr 9 16:48:53 2019 +0100 RNG-88: Fixed javadoc and track changes. Closes #35 --- .../rng/examples/jmh/AbstractBenchmark.java | 2 +- .../jmh/BaselineGenerationPerformance.java | 4 ++-- .../commons/rng/examples/jmh/BaselineSources.java | 2 +- .../commons/rng/examples/jmh/BaselineUtils.java | 22 +++++++--------------- .../jmh/FloatingPointGenerationPerformance.java | 2 +- .../jmh/NextBooleanGenerationPerformance.java | 2 +- .../jmh/NextBytesGenerationPerformance.java | 5 ++++- .../jmh/NextDoubleGenerationPerformance.java | 2 +- .../jmh/NextFloatGenerationPerformance.java | 2 +- .../examples/jmh/NextIntGenerationPerformance.java | 2 +- .../jmh/NextLongGenerationPerformance.java | 2 +- src/changes/changes.xml | 3 +++ 12 files changed, 24 insertions(+), 26 deletions(-) diff --git a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/AbstractBenchmark.java b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/AbstractBenchmark.java index 09d2b6d..4b6e6fe 100644 --- a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/AbstractBenchmark.java +++ b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/AbstractBenchmark.java @@ -35,7 +35,7 @@ import java.util.concurrent.TimeUnit; * * <p>Note: Implementing this as an {@code @interface} annotation results in errors as the * meta-annotation is not expanded by the JMH annotation processor. The processor does however - * allow all annotations to be inherited from abstract classes. + * allow all annotations to be inherited from abstract classes.</p> */ @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) diff --git a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/BaselineGenerationPerformance.java b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/BaselineGenerationPerformance.java index 1a94885..9fc0a8c 100644 --- a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/BaselineGenerationPerformance.java +++ b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/BaselineGenerationPerformance.java @@ -127,7 +127,7 @@ public class BaselineGenerationPerformance { * * <p>Note: Following the convention in the JMH Blackhole::consumCPU(long) method * the loops are constructed to count down (although since there is no consumption - * of the loop counter the loop construct may be rewritten anyway). + * of the loop counter the loop construct may be rewritten anyway).</p> */ @Param({"50000", "100000", "150000", "200000", "250000"}) private int numValues; @@ -137,7 +137,7 @@ public class BaselineGenerationPerformance { * * <p>Note: Currently there is not a test for * {@link UniformRandomProvider#nextBytes(byte[], int, int)} since the two methods are - * implemented by the base Int/LongProvider class using the same code. + * implemented by the base Int/LongProvider class using the same code.</p> * * @param bh Data sink. */ diff --git a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/BaselineSources.java b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/BaselineSources.java index d5d55ad..bb5c78e 100644 --- a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/BaselineSources.java +++ b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/BaselineSources.java @@ -29,7 +29,7 @@ import org.openjdk.jmh.annotations.State; * Defines the benchmark state to retrieve the various "RandomSource"s. * * <p>A baseline implementation for the {@link UniformRandomProvider} must be provided by - * implementing classes. + * implementing classes.</p> */ @State(Scope.Benchmark) public abstract class BaselineSources { diff --git a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/BaselineUtils.java b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/BaselineUtils.java index a882f2c..876e23b 100644 --- a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/BaselineUtils.java +++ b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/BaselineUtils.java @@ -31,7 +31,7 @@ public final class BaselineUtils { * * <p>Note: This is not a good baseline as the JVM can optimise the predictable result * of the method calls. This is here for convenience when implementing - * UniformRandomProvider. + * UniformRandomProvider.</p> */ private abstract static class DefaultProvider implements UniformRandomProvider { @Override @@ -62,14 +62,6 @@ public final class BaselineUtils { public double nextDouble() { return 0; } } - // The baseline implementation of nextBytes has 2 options: - // - // 1. Copy the same value into each positions. - // 2. Increment a counter and copy into each position. - // - // Option 1 provides the opportunity for the JVM to inline the copy through the array. - // Option 2 introduces a counter overhead. - /** * Baseline implementation for {@link UniformRandomProvider#nextBytes(byte[])} and * {@link UniformRandomProvider#nextBytes(byte[], int, int)}. @@ -79,7 +71,7 @@ public final class BaselineUtils { * The fixed value to fill the byte array. * * <p><strong>DON'T</strong> make this final! - * This must be a viewed by the JVM as something that cannot be optimised away. + * This must be a viewed by the JVM as something that cannot be optimised away.</p> */ private byte value; @@ -107,7 +99,7 @@ public final class BaselineUtils { * The fixed value to return. * * <p><strong>DON'T</strong> make this final! - * This must be a viewed by the JVM as something that cannot be optimised away. + * This must be a viewed by the JVM as something that cannot be optimised away.</p> */ private int value; @@ -131,7 +123,7 @@ public final class BaselineUtils { * The fixed value to return. * * <p><strong>DON'T</strong> make this final! - * This must be a viewed by the JVM as something that cannot be optimised away. + * This must be a viewed by the JVM as something that cannot be optimised away.</p> */ private long value; @@ -154,7 +146,7 @@ public final class BaselineUtils { * The fixed value to return. * * <p><strong>DON'T</strong> make this final! - * This must be a viewed by the JVM as something that cannot be optimised away. + * This must be a viewed by the JVM as something that cannot be optimised away.</p> */ private boolean value; @@ -172,7 +164,7 @@ public final class BaselineUtils { * The fixed value to return. * * <p><strong>DON'T</strong> make this final! - * This must be a viewed by the JVM as something that cannot be optimised away. + * This must be a viewed by the JVM as something that cannot be optimised away.</p> */ private float value; @@ -190,7 +182,7 @@ public final class BaselineUtils { * The fixed value to return. * * <p><strong>DON'T</strong> make this final! - * This must be a viewed by the JVM as something that cannot be optimised away. + * This must be a viewed by the JVM as something that cannot be optimised away.</p> */ private double value; diff --git a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/FloatingPointGenerationPerformance.java b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/FloatingPointGenerationPerformance.java index 5125032..146ebec 100644 --- a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/FloatingPointGenerationPerformance.java +++ b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/FloatingPointGenerationPerformance.java @@ -45,7 +45,7 @@ public class FloatingPointGenerationPerformance { * Mimic the generation of the SplitMix64 algorithm. * * <p>The final mixing step must be included otherwise the output numbers are sequential - * and the test may run with a lack of numbers with higher order bits. + * and the test may run with a lack of numbers with higher order bits.</p> */ @State(Scope.Benchmark) public static class LongSource { diff --git a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/NextBooleanGenerationPerformance.java b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/NextBooleanGenerationPerformance.java index 4af04e7..5621c8a 100644 --- a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/NextBooleanGenerationPerformance.java +++ b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/NextBooleanGenerationPerformance.java @@ -38,7 +38,7 @@ public class NextBooleanGenerationPerformance extends AbstractBenchmark { } } - /** The value. */ + /** The value. Must NOT be final to prevent JVM optimisation! */ private boolean value; /** diff --git a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/NextBytesGenerationPerformance.java b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/NextBytesGenerationPerformance.java index ba44416..19041c3 100644 --- a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/NextBytesGenerationPerformance.java +++ b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/NextBytesGenerationPerformance.java @@ -38,7 +38,10 @@ public class NextBytesGenerationPerformance extends AbstractBenchmark { } } - /** The value. This is a pre-allocated array. */ + /** + * The value. This is a pre-allocated array. Must NOT be final to prevent JVM + * optimisation! + */ private byte[] value = new byte[BaselineGenerationPerformance.NEXT_BYTES_SIZE]; /** diff --git a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/NextDoubleGenerationPerformance.java b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/NextDoubleGenerationPerformance.java index 0919e59..cfa40b2 100644 --- a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/NextDoubleGenerationPerformance.java +++ b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/NextDoubleGenerationPerformance.java @@ -38,7 +38,7 @@ public class NextDoubleGenerationPerformance extends AbstractBenchmark { } } - /** The value. */ + /** The value. Must NOT be final to prevent JVM optimisation! */ private double value; /** diff --git a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/NextFloatGenerationPerformance.java b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/NextFloatGenerationPerformance.java index ec63bed..fbd4366 100644 --- a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/NextFloatGenerationPerformance.java +++ b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/NextFloatGenerationPerformance.java @@ -38,7 +38,7 @@ public class NextFloatGenerationPerformance extends AbstractBenchmark { } } - /** The value. */ + /** The value. Must NOT be final to prevent JVM optimisation! */ private float value; /** diff --git a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/NextIntGenerationPerformance.java b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/NextIntGenerationPerformance.java index f10e949..5b582b0 100644 --- a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/NextIntGenerationPerformance.java +++ b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/NextIntGenerationPerformance.java @@ -39,7 +39,7 @@ public class NextIntGenerationPerformance extends AbstractBenchmark { } } - /** The value. */ + /** The value. Must NOT be final to prevent JVM optimisation! */ private int value; /** diff --git a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/NextLongGenerationPerformance.java b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/NextLongGenerationPerformance.java index 2a71f80..f77fd7f 100644 --- a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/NextLongGenerationPerformance.java +++ b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/NextLongGenerationPerformance.java @@ -39,7 +39,7 @@ public class NextLongGenerationPerformance extends AbstractBenchmark { } } - /** The value. */ + /** The value. Must NOT be final to prevent JVM optimisation! */ private long value; /** diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 5a9b4e5..128dbd4 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -75,6 +75,9 @@ re-run tests that fail, and pass the build if they succeed within the allotted number of reruns (the test will be marked as 'flaky' in the report). "> + <action dev="aherbert" type="update" issue="RNG-88"> + Update the generation performance JMH benchmarks to have a reference baseline. + </action> <action dev="aherbert" type="update" issue="RNG-87"> "MultiplyWithCarry256": Performance improvement by advancing state one step per sample. </action>