changeset 267:fd83add52cba

Fix the build breakage + break the API in consistent way. NOTE: getConfidenceInterval and getConfidenceIntervalAt accept different parameters.
author shade
date Fri, 22 Nov 2013 18:29:11 +0400
parents 51264eec1d55
children 23317fcda782
files jmh-core-benchmarks/src/main/java/org/openjdk/jmh/MainValidation.java jmh-core/src/main/java/org/openjdk/jmh/logic/results/Result.java jmh-core/src/main/java/org/openjdk/jmh/logic/results/SampleTimeResult.java jmh-core/src/main/java/org/openjdk/jmh/output/format/TextReportFormat.java jmh-core/src/main/java/org/openjdk/jmh/output/results/CSVResultFormat.java jmh-core/src/main/java/org/openjdk/jmh/output/results/JSONResultFormat.java jmh-core/src/main/java/org/openjdk/jmh/util/internal/AbstractStatistics.java jmh-core/src/main/java/org/openjdk/jmh/util/internal/Statistics.java jmh-core/src/test/java/org/openjdk/jmh/util/TestListStatistics.java jmh-core/src/test/java/org/openjdk/jmh/util/TestMultisetStatistics.java
diffstat 10 files changed, 36 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/MainValidation.java	Fri Nov 22 18:18:08 2013 +0400
+++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/MainValidation.java	Fri Nov 22 18:29:11 2013 +0400
@@ -32,15 +32,12 @@
 import org.openjdk.jmh.logic.results.Result;
 import org.openjdk.jmh.logic.results.RunResult;
 import org.openjdk.jmh.output.OutputFormatType;
-import org.openjdk.jmh.runner.BenchmarkRecord;
 import org.openjdk.jmh.runner.Runner;
 import org.openjdk.jmh.runner.RunnerException;
 import org.openjdk.jmh.runner.options.Options;
 import org.openjdk.jmh.runner.options.OptionsBuilder;
 
 import java.io.PrintWriter;
-import java.util.Arrays;
-import java.util.Map;
 
 public class MainValidation {
 
@@ -73,7 +70,7 @@
 
             pw.printf("%50s", "running empty benchmark: ");
             pw.flush();
-            pw.printf("%.2f +- %.2f ns\n", r.getScore(), r.getStatistics().getMeanError(0.999));
+            pw.printf("%.2f +- %.2f ns\n", r.getScore(), r.getStatistics().getMeanErrorAt(0.999));
         }
 
         {
@@ -87,7 +84,7 @@
 
             pw.printf("%50s", "Level.Trial, Scope.Benchmark, @Setup: ");
             pw.flush();
-            pw.printf("%.2f +- %.2f ns\n", r.getScore(), r.getStatistics().getMeanError(0.999));
+            pw.printf("%.2f +- %.2f ns\n", r.getScore(), r.getStatistics().getMeanErrorAt(0.999));
         }
 
         {
@@ -101,7 +98,7 @@
 
             pw.printf("%50s", "Level.Trial, Scope.Benchmark, @TearDown: ");
             pw.flush();
-            pw.printf("%.2f +- %.2f ns\n", r.getScore(), r.getStatistics().getMeanError(0.999));
+            pw.printf("%.2f +- %.2f ns\n", r.getScore(), r.getStatistics().getMeanErrorAt(0.999));
         }
 
         {
@@ -115,7 +112,7 @@
 
             pw.printf("%50s", "Level.Iteration, Scope.Benchmark, @Setup: ");
             pw.flush();
-            pw.printf("%.2f +- %.2f ns\n", r.getScore(), r.getStatistics().getMeanError(0.999));
+            pw.printf("%.2f +- %.2f ns\n", r.getScore(), r.getStatistics().getMeanErrorAt(0.999));
         }
 
         {
@@ -129,7 +126,7 @@
 
             pw.printf("%50s", "Level.Iteration, Scope.Benchmark, @TearDown: ");
             pw.flush();
-            pw.printf("%.2f +- %.2f ns\n", r.getScore(), r.getStatistics().getMeanError(0.999));
+            pw.printf("%.2f +- %.2f ns\n", r.getScore(), r.getStatistics().getMeanErrorAt(0.999));
         }
 
         {
@@ -143,7 +140,7 @@
 
             pw.printf("%50s", "Level.Invocation, Scope.Benchmark, @Setup: ");
             pw.flush();
-            pw.printf("%.2f +- %.2f ns\n", r.getScore(), r.getStatistics().getMeanError(0.999));
+            pw.printf("%.2f +- %.2f ns\n", r.getScore(), r.getStatistics().getMeanErrorAt(0.999));
         }
 
         {
@@ -157,7 +154,7 @@
 
             pw.printf("%50s", "Level.Invocation, Scope.Benchmark, @TearDown: ");
             pw.flush();
-            pw.printf("%.2f +- %.2f ns\n", r.getScore(), r.getStatistics().getMeanError(0.999));
+            pw.printf("%.2f +- %.2f ns\n", r.getScore(), r.getStatistics().getMeanErrorAt(0.999));
         }
 
         pw.println();
@@ -183,7 +180,7 @@
 
             pw.printf("%50s", "System.nanoTime latency: ");
             pw.flush();
-            pw.printf("%.2f +- %.2f ns\n", r.getScore(), r.getStatistics().getMeanError(0.999));
+            pw.printf("%.2f +- %.2f ns\n", r.getScore(), r.getStatistics().getMeanErrorAt(0.999));
 
             latency = (long) r.getScore();
         }
@@ -200,7 +197,7 @@
 
             pw.printf("%50s", "System.nanoTime granularity: ");
             pw.flush();
-            pw.printf("%.2f +- %.2f ns\n", r.getScore(), r.getStatistics().getMeanError(0.999));
+            pw.printf("%.2f +- %.2f ns\n", r.getScore(), r.getStatistics().getMeanErrorAt(0.999));
             granularity = (long) r.getScore();
         }
 
--- a/jmh-core/src/main/java/org/openjdk/jmh/logic/results/Result.java	Fri Nov 22 18:18:08 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/logic/results/Result.java	Fri Nov 22 18:29:11 2013 +0400
@@ -91,7 +91,7 @@
         PrintWriter pw = new PrintWriter(sw);
 
         if (statistics.getN() > 2) {
-            double[] interval = statistics.getConfidenceInterval(0.999);
+            double[] interval = statistics.getConfidenceIntervalAt(0.999);
             pw.println(String.format("Result %s: %.3f \u00B1(99.9%%) %.3f %s",
                     (label == null) ? "" : "\"" + label + "\"",
                     statistics.getMean(), (interval[1] - interval[0]) / 2,
--- a/jmh-core/src/main/java/org/openjdk/jmh/logic/results/SampleTimeResult.java	Fri Nov 22 18:18:08 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/logic/results/SampleTimeResult.java	Fri Nov 22 18:29:11 2013 +0400
@@ -117,7 +117,7 @@
         sb.append("    samples = ").append(stats.getN()).append("\n");
 
         if (stats.getN() > 2) {
-            double[] interval = stats.getConfidenceInterval(0.999);
+            double[] interval = stats.getConfidenceIntervalAt(0.999);
             sb.append(String.format("        mean = %10.3f \u00B1(99.9%%) %.3f",
                     convertNs(stats.getMean()),
                     convertNs((interval[1] - interval[0]) / 2)
--- a/jmh-core/src/main/java/org/openjdk/jmh/output/format/TextReportFormat.java	Fri Nov 22 18:18:08 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/output/format/TextReportFormat.java	Fri Nov 22 18:29:11 2013 +0400
@@ -191,7 +191,7 @@
                         key.getMode().shortLabel(),
                         threads, stats.getN(),
                         runTime.convertTo(TimeUnit.SECONDS),
-                        stats.getMean(), stats.getMeanError(0.999),
+                        stats.getMean(), stats.getMeanErrorAt(0.999),
                         res.getScoreUnit());
             }
 
@@ -203,7 +203,7 @@
                         key.getMode().shortLabel(),
                         threads, stats.getN(),
                         runTime.convertTo(TimeUnit.SECONDS),
-                        stats.getMean(), stats.getMeanError(0.999),
+                        stats.getMean(), stats.getMeanErrorAt(0.999),
                         res.getScoreUnit());
             }
         }
--- a/jmh-core/src/main/java/org/openjdk/jmh/output/results/CSVResultFormat.java	Fri Nov 22 18:18:08 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/output/results/CSVResultFormat.java	Fri Nov 22 18:29:11 2013 +0400
@@ -63,7 +63,7 @@
                 pw.print("\", ");
                 pw.print(runResult.getPrimaryResult().getStatistics().getMean());
                 pw.print(", ");
-                pw.print(runResult.getPrimaryResult().getStatistics().getMeanError(0.999));
+                pw.print(runResult.getPrimaryResult().getStatistics().getMeanErrorAt(0.999));
                 pw.print(", \"");
                 pw.print(runResult.getPrimaryResult().getScoreUnit());
                 pw.println("\"");
--- a/jmh-core/src/main/java/org/openjdk/jmh/output/results/JSONResultFormat.java	Fri Nov 22 18:18:08 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/output/results/JSONResultFormat.java	Fri Nov 22 18:29:11 2013 +0400
@@ -69,9 +69,9 @@
                 pw.println("  \"primaryMetric\" : {");
                 pw.println("    \"score\" : " + runResult.getPrimaryResult().getScore() + ",");
                 pw.println("    \"scoreStdev\" : " + runResult.getPrimaryResult().getStatistics().getStandardDeviation() + ",");
-                pw.println("    \"scoreConfidence95\" : " + Arrays.toString(runResult.getPrimaryResult().getStatistics().getConfidenceInterval(0.95)) + ",");
-                pw.println("    \"scoreConfidence99\" : " + Arrays.toString(runResult.getPrimaryResult().getStatistics().getConfidenceInterval(0.99)) + ",");
-                pw.println("    \"scoreConfidence999\" : " + Arrays.toString(runResult.getPrimaryResult().getStatistics().getConfidenceInterval(0.999)) + ",");
+                pw.println("    \"scoreConfidence95\" : " + Arrays.toString(runResult.getPrimaryResult().getStatistics().getConfidenceIntervalAt(0.95)) + ",");
+                pw.println("    \"scoreConfidence99\" : " + Arrays.toString(runResult.getPrimaryResult().getStatistics().getConfidenceIntervalAt(0.99)) + ",");
+                pw.println("    \"scoreConfidence999\" : " + Arrays.toString(runResult.getPrimaryResult().getStatistics().getConfidenceIntervalAt(0.999)) + ",");
                 pw.println("    \"scoreUnit\" : \"" + runResult.getPrimaryResult().getScoreUnit() + "\",");
                 pw.println("    \"rawData\" : [");
 
--- a/jmh-core/src/main/java/org/openjdk/jmh/util/internal/AbstractStatistics.java	Fri Nov 22 18:18:08 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/util/internal/AbstractStatistics.java	Fri Nov 22 18:29:11 2013 +0400
@@ -137,7 +137,7 @@
      * @return the confidence interval
      */
     @Override
-    public double[] getConfidenceInterval(double confidence) {
+    public double[] getConfidenceIntervalAt(double confidence) {
         double[] interval = new double[2];
 
         double ip = getStudentT(1 - (1 - confidence)/2, getN() - 1);
@@ -168,8 +168,8 @@
     }
 
     @Override
-    public double getMeanError(double confidence) {
-        if (getN() < 2) return Double.NaN;
+    public double getMeanErrorAt(double confidence) {
+        if (getN() <= 2) return Double.NaN;
         double ip = getStudentT(1 - (1 - confidence)/2, getN() - 1);
         return ip * (getStandardDeviation() / Math.sqrt(getN()));
     }
--- a/jmh-core/src/main/java/org/openjdk/jmh/util/internal/Statistics.java	Fri Nov 22 18:18:08 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/util/internal/Statistics.java	Fri Nov 22 18:29:11 2013 +0400
@@ -28,9 +28,19 @@
 
 public interface Statistics extends Serializable {
 
-    double[] getConfidenceInterval(double confidence);
+    /**
+     * Gets the confidence interval at given confidence level.
+     * @param confidence confidence level (e.g. 0.95)
+     * @return the interval in which mean lies with the given confidence level
+     */
+    double[] getConfidenceIntervalAt(double confidence);
 
-    double getMeanError(double confidence);
+    /**
+     * Gets the mean error at given confidence level.
+     * @param confidence confidence level (e.g. 0.95)
+     * @return the mean error with the given confidence level
+     */
+    double getMeanErrorAt(double confidence);
 
     double getStandardDeviation();
 
--- a/jmh-core/src/test/java/org/openjdk/jmh/util/TestListStatistics.java	Fri Nov 22 18:18:08 2013 +0400
+++ b/jmh-core/src/test/java/org/openjdk/jmh/util/TestListStatistics.java	Fri Nov 22 18:29:11 2013 +0400
@@ -127,11 +127,11 @@
     }
 
     /**
-     * Test of getConfidenceInterval, of class Statistics
+     * Test of getConfidenceIntervalAt, of class Statistics
      */
     @Test
     public strictfp void testGetConfidenceInterval() {
-        double[] interval = instance.getConfidenceInterval(0.95);
+        double[] interval = instance.getConfidenceIntervalAt(0.95);
         assertEquals(39.234, interval[0], 0.002);
         assertEquals(62.831, interval[1], 0.002);
     }
--- a/jmh-core/src/test/java/org/openjdk/jmh/util/TestMultisetStatistics.java	Fri Nov 22 18:18:08 2013 +0400
+++ b/jmh-core/src/test/java/org/openjdk/jmh/util/TestMultisetStatistics.java	Fri Nov 22 18:29:11 2013 +0400
@@ -128,11 +128,11 @@
     }
 
     /**
-     * Test of getConfidenceInterval, of class Statistics
+     * Test of getConfidenceIntervalAt, of class Statistics
      */
     @Test
     public strictfp void testGetConfidenceInterval() {
-        double[] interval = instance.getConfidenceInterval(0.95);
+        double[] interval = instance.getConfidenceIntervalAt(0.95);
         assertEquals(39.234, interval[0], 0.002);
         assertEquals(62.831, interval[1], 0.002);
     }