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
The following commit(s) were added to refs/heads/master by this push:
new b571fa9 Results command to summarise PractRand failure length if all
failed.
b571fa9 is described below
commit b571fa9dde3e0eb342c9e7bf5937bcb5586d92db
Author: Alex Herbert <[email protected]>
AuthorDate: Sat Oct 19 18:03:23 2019 +0100
Results command to summarise PractRand failure length if all failed.
---
.../rng/examples/stress/ResultsCommand.java | 31 +++++++++++++++++-----
1 file changed, 25 insertions(+), 6 deletions(-)
diff --git
a/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/ResultsCommand.java
b/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/ResultsCommand.java
index 53c097a..c05a51e 100644
---
a/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/ResultsCommand.java
+++
b/commons-rng-examples/examples-stress/src/main/java/org/apache/commons/rng/examples/stress/ResultsCommand.java
@@ -16,7 +16,6 @@
*/
package org.apache.commons.rng.examples.stress;
-import org.apache.commons.rng.examples.stress.ResultsCommand.TestFormat;
import org.apache.commons.rng.simple.RandomSource;
import picocli.CommandLine.Command;
@@ -351,6 +350,7 @@ class ResultsCommand implements Callable<Void> {
/**
* Gets the length of the RNG output used to generate failed tests.
+ * If this is zero then no failures occurred.
*
* @return the length exponent
*/
@@ -1272,7 +1272,12 @@ class ResultsCommand implements Callable<Void> {
}
/**
- * Gets the maximum length exponent from any PractRand results.
+ * Gets the maximum length exponent from the PractRand results if
<strong>all</strong> failed.
+ * Otherwise return zero (i.e. some passed the full length of the test).
+ *
+ * <p>This method excludes those results that are not complete. It assumes
all complete
+ * tests are for the same length of RNG output. Thus if all failed then
the max exponent
+ * is the systematic failure length.</p>
*
* @param results Results.
* @return the maximum length exponent (or zero)
@@ -1281,10 +1286,24 @@ class ResultsCommand implements Callable<Void> {
if (results.isEmpty()) {
return 0;
}
- return results.stream()
- .filter(r -> r instanceof PractRandTestResult)
- .mapToInt(r -> ((PractRandTestResult)
r).getLengthExponent())
- .max().orElse(0);
+ // [0] = count of zeros
+ // [1] = max non-zero
+ final int[] data = new int[2];
+ results.stream()
+ .filter(TestResult::isComplete)
+ .filter(r -> r instanceof PractRandTestResult)
+ .mapToInt(r -> ((PractRandTestResult) r).getLengthExponent())
+ .forEach(i -> {
+ if (i == 0) {
+ // Count results that passed
+ data[0]++;
+ } else {
+ // Find the max of the failures
+ data[1] = Math.max(i, data[1]);
+ }
+ });
+ // If all failed (i.e. no zeros) then return the max, otherwise zero.
+ return data[0] == 0 ? data[1] : 0;
}
/**