changeset 1186:96d8047fbf9a

7901372: Improve the formatting for Result extended info
author shade
date Mon, 06 Apr 2015 14:13:24 +0300
parents 1773a7a253e9
children 43fd19824f3f
files jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerResult.java jmh-core/src/main/java/org/openjdk/jmh/profile/StackProfiler.java jmh-core/src/main/java/org/openjdk/jmh/results/Result.java jmh-core/src/main/java/org/openjdk/jmh/results/SampleTimeResult.java jmh-core/src/main/java/org/openjdk/jmh/results/SingleShotResult.java jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java
diffstat 9 files changed, 22 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java	Sun Apr 05 16:06:15 2015 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java	Mon Apr 06 14:13:24 2015 +0300
@@ -790,7 +790,7 @@
         }
 
         @Override
-        public String extendedInfo(String label) {
+        public String extendedInfo() {
             return output;
         }
     }
--- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java	Sun Apr 05 16:06:15 2015 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java	Mon Apr 06 14:13:24 2015 +0300
@@ -327,7 +327,7 @@
         }
 
         @Override
-        public String extendedInfo(String label) {
+        public String extendedInfo() {
             return "";
         }
     }
--- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java	Sun Apr 05 16:06:15 2015 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java	Mon Apr 06 14:13:24 2015 +0300
@@ -224,7 +224,7 @@
         }
 
         @Override
-        public String extendedInfo(String label) {
+        public String extendedInfo() {
             return "Perf stats:\n--------------------------------------------------\n" + output;
         }
     }
--- a/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerResult.java	Sun Apr 05 16:06:15 2015 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerResult.java	Mon Apr 06 14:13:24 2015 +0300
@@ -28,7 +28,6 @@
 import org.openjdk.jmh.results.Aggregator;
 import org.openjdk.jmh.results.Result;
 import org.openjdk.jmh.results.ResultRole;
-import org.openjdk.jmh.util.ScoreFormatter;
 import org.openjdk.jmh.util.Statistics;
 
 public class ProfilerResult extends Result<ProfilerResult> {
@@ -52,17 +51,4 @@
         return new ProfilerResultAggregator();
     }
 
-    public String extendedInfo(String label) {
-        switch (policy) {
-            case AVG:
-                return String.format("Result %30s: %s ±(99.9%%) %s %s", "\"" + label + "\"", ScoreFormatter.format(getScore()), ScoreFormatter.format(getScoreError()), getScoreUnit());
-            case MAX:
-            case SUM:
-                return String.format("Result %30s: %s %s [%s]", "\"" + label + "\"", ScoreFormatter.format(getScore()), getScoreUnit(), policy);
-            default:
-                throw new IllegalStateException("Unknown policy: " + policy);
-        }
-
-    }
-
 }
--- a/jmh-core/src/main/java/org/openjdk/jmh/profile/StackProfiler.java	Sun Apr 05 16:06:15 2015 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/StackProfiler.java	Mon Apr 06 14:13:24 2015 +0300
@@ -266,7 +266,7 @@
         }
 
         @Override
-        public String extendedInfo(String label) {
+        public String extendedInfo() {
             return getStack(stacks);
         }
 
--- a/jmh-core/src/main/java/org/openjdk/jmh/results/Result.java	Sun Apr 05 16:06:15 2015 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/results/Result.java	Mon Apr 06 14:13:24 2015 +0300
@@ -191,27 +191,25 @@
 
     /**
      * Print extended result information
-     * @param label result label
      * @return String with extended info
      */
-    public String extendedInfo(String label) {
-        return simpleExtendedInfo(label);
+    public String extendedInfo() {
+        return simpleExtendedInfo();
     }
 
-    protected String simpleExtendedInfo(String label) {
+    protected String simpleExtendedInfo() {
         StringWriter sw = new StringWriter();
         PrintWriter pw = new PrintWriter(sw);
 
         Statistics stats = getStatistics();
         if (stats.getN() > 2 && !ScoreFormatter.isApproximate(getScore())) {
             double[] interval = getScoreConfidence();
-            pw.println(String.format("Result%s: %s \u00B1(99.9%%) %s %s [%s]",
-                    (label == null) ? "" : " \"" + label + "\"",
+            pw.println(String.format("  %s \u00B1(99.9%%) %s %s [%s]",
                     ScoreFormatter.format(getScore()),
                     ScoreFormatter.formatError((interval[1] - interval[0]) / 2),
                     getScoreUnit(), policy));
-            pw.println(String.format("  Statistics: (min, avg, max) = (%s, %s, %s), stdev = %s%n" +
-                    "  Confidence interval (99.9%%): [%s, %s]",
+            pw.println(String.format("  (min, avg, max) = (%s, %s, %s), stdev = %s%n" +
+                    "  CI (99.9%%): [%s, %s] (assumes normal distribution)",
                     ScoreFormatter.format(stats.getMin()),
                     ScoreFormatter.format(stats.getMean()),
                     ScoreFormatter.format(stats.getMax()),
@@ -220,13 +218,13 @@
                     ScoreFormatter.format(interval[1]))
             );
         } else {
-            pw.println(String.format("Run result: %s %s", ScoreFormatter.format(stats.getMean()), getScoreUnit()));
+            pw.println(String.format("  %s %s", ScoreFormatter.format(stats.getMean()), getScoreUnit()));
         }
         pw.close();
         return sw.toString();
     }
 
-    protected String percentileExtendedInfo(String label) {
+    protected String percentileExtendedInfo() {
         Statistics stats = getStatistics();
 
         StringBuilder sb = new StringBuilder();
@@ -241,7 +239,7 @@
             ));
             sb.append(" ").append(getScoreUnit()).append("\n");
 
-            sb.append(String.format("         min = %s %s\n", ScoreFormatter.format(stats.getMin()), getScoreUnit()));
+            sb.append(String.format("         min = %s %s\n", ScoreFormatter.format(10, stats.getMin()), getScoreUnit()));
 
             for (double p : new double[]{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 0.99999, 0.999999}) {
                 sb.append(String.format("  %9s = %s %s\n",
--- a/jmh-core/src/main/java/org/openjdk/jmh/results/SampleTimeResult.java	Sun Apr 05 16:06:15 2015 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/results/SampleTimeResult.java	Mon Apr 06 14:13:24 2015 +0300
@@ -84,8 +84,8 @@
     }
 
     @Override
-    public String extendedInfo(String label) {
-        return simpleExtendedInfo(label) + percentileExtendedInfo(label);
+    public String extendedInfo() {
+        return simpleExtendedInfo() + percentileExtendedInfo();
     }
 
     @Override
--- a/jmh-core/src/main/java/org/openjdk/jmh/results/SingleShotResult.java	Sun Apr 05 16:06:15 2015 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/results/SingleShotResult.java	Mon Apr 06 14:13:24 2015 +0300
@@ -48,8 +48,8 @@
     }
 
     @Override
-    public String extendedInfo(String label) {
-        return simpleExtendedInfo(label) + percentileExtendedInfo(label);
+    public String extendedInfo() {
+        return simpleExtendedInfo() + percentileExtendedInfo();
     }
 
     @Override
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java	Sun Apr 05 16:06:15 2015 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java	Mon Apr 06 14:13:24 2015 +0300
@@ -155,14 +155,17 @@
         out.println();
         if (result != null) {
             {
-                String s = result.getPrimaryResult().extendedInfo(null);
+                Result r = result.getPrimaryResult();
+                String s = r.extendedInfo();
                 if (!s.trim().isEmpty()) {
+                    out.println("Result \"" + r.getLabel() + "\":");
                     out.println(s);
                 }
             }
             for (Result r : result.getSecondaryResults().values()) {
-                String s = r.extendedInfo(r.getLabel());
+                String s = r.extendedInfo();
                 if (!s.trim().isEmpty()) {
+                    out.println("Secondary result \"" + r.getLabel() + "\":");
                     out.println(s);
                 }
             }