changeset 1161:9d9c35e9cf04

7901347: Text report improvements: don't print "NaN" in errors, etc
author shade
date Thu, 19 Mar 2015 22:28:25 +0300
parents ea66b1770352
children 0ea217986c8e
files jmh-core/src/main/java/org/openjdk/jmh/results/format/TextResultFormat.java jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.text.root jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.text.ru jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.text.us
diffstat 5 files changed, 58 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/results/format/TextResultFormat.java	Thu Mar 19 18:54:37 2015 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/results/format/TextResultFormat.java	Thu Mar 19 22:28:25 2015 +0300
@@ -133,10 +133,22 @@
 
                 Result pRes = res.getPrimaryResult();
                 out.print(String.format("%" + modeLen + "s",        res.getParams().getMode().shortLabel()));
-                out.print(String.format("%" + samplesLen + "d",     pRes.getSampleCount()));
+
+                if (pRes.getSampleCount() > 1) {
+                    out.print(String.format("%" + samplesLen + "d", pRes.getSampleCount()));
+                } else {
+                    out.printf("%" + (samplesLen) + "s", "");
+                }
+
                 out.print(String.format("%" + scoreLen + ".3f",     pRes.getScore()));
-                out.print(" \u00B1");
-                out.print(String.format("%" + scoreErrLen + ".3f",  pRes.getScoreError()));
+
+                if (!Double.isNaN(pRes.getScoreError())) {
+                    out.print(" \u00B1");
+                    out.print(String.format("%" + scoreErrLen + ".3f",  pRes.getScoreError()));
+                } else {
+                    out.printf("%" + (scoreErrLen + 2) + "s", "");
+                }
+
                 out.print(String.format("%" + unitLen + "s",        pRes.getScoreUnit()));
                 out.println();
             }
@@ -154,10 +166,22 @@
                 }
 
                 out.print(String.format("%" + modeLen + "s",        res.getParams().getMode().shortLabel()));
-                out.print(String.format("%" + samplesLen + "d",     subRes.getSampleCount()));
+
+                if (subRes.getSampleCount() > 1) {
+                    out.print(String.format("%" + samplesLen + "d", subRes.getSampleCount()));
+                } else {
+                    out.printf("%" + (samplesLen) + "s", "");
+                }
+
                 out.print(String.format("%" + scoreLen + ".3f",     subRes.getScore()));
-                out.print(" \u00B1");
-                out.print(String.format("%" + scoreErrLen + ".3f",  subRes.getScoreError()));
+
+                if (!Double.isNaN(subRes.getScoreError())) {
+                    out.print(" \u00B1");
+                    out.print(String.format("%" + scoreErrLen + ".3f",  subRes.getScoreError()));
+                } else {
+                    out.printf("%" + (scoreErrLen + 2) + "s", "");
+                }
+
                 out.print(String.format("%" + unitLen + "s",        subRes.getScoreUnit()));
                 out.println();
             }
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java	Thu Mar 19 18:54:37 2015 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java	Thu Mar 19 22:28:25 2015 +0300
@@ -154,9 +154,17 @@
     public void endBenchmark(BenchmarkResult result) {
         out.println();
         if (result != null) {
-            out.println(result.getPrimaryResult().extendedInfo(null));
+            {
+                String s = result.getPrimaryResult().extendedInfo(null);
+                if (!s.trim().isEmpty()) {
+                    out.println(s);
+                }
+            }
             for (Result r : result.getSecondaryResults().values()) {
-                out.println(r.extendedInfo(r.getLabel()));
+                String s = r.extendedInfo(r.getLabel());
+                if (!s.trim().isEmpty()) {
+                    out.println(s);
+                }
             }
             out.println();
         }
--- a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.text.root	Thu Mar 19 18:54:37 2015 +0300
+++ b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.text.root	Thu Mar 19 22:28:25 2015 +0300
@@ -2,15 +2,15 @@
 benchmark_0               value0    value1    value2    value3    value4  thrpt   14  528.857 ± 278.142  ops/ms
 benchmark_0:secondary1    value0    value1    value2    value3    value4  thrpt   14  549.714 ± 320.227  ops/ms
 benchmark_0:secondary2    value0    value1    value2    value3    value4  thrpt   14  615.500 ± 319.210  ops/ms
-benchmark_1               value0    value1    value2    value3    value4  thrpt    1  439.000 ±     NaN  ops/ms
-benchmark_1:secondary1    value0    value1    value2    value3    value4  thrpt    1  953.000 ±     NaN  ops/ms
-benchmark_1:secondary2    value0    value1    value2    value3    value4  thrpt    1  367.000 ±     NaN  ops/ms
+benchmark_1               value0    value1    value2    value3    value4  thrpt       439.000            ops/ms
+benchmark_1:secondary1    value0    value1    value2    value3    value4  thrpt       953.000            ops/ms
+benchmark_1:secondary2    value0    value1    value2    value3    value4  thrpt       367.000            ops/ms
 benchmark_2               value0    value1    value2    value3    value4  thrpt    9  545.000 ± 553.337  ops/ms
 benchmark_2:secondary1    value0    value1    value2    value3    value4  thrpt    9  434.444 ± 465.183  ops/ms
 benchmark_2:secondary2    value0    value1    value2    value3    value4  thrpt    9  470.333 ± 502.273  ops/ms
 benchmark_3               value0    value1    value2    value3    value4  thrpt   14  417.571 ± 362.814  ops/ms
 benchmark_3:secondary1    value0    value1    value2    value3    value4  thrpt   14  672.214 ± 287.982  ops/ms
 benchmark_3:secondary2    value0    value1    value2    value3    value4  thrpt   14  560.143 ± 289.800  ops/ms
-benchmark_4               value0    value1    value2    value3    value4  thrpt    1  956.000 ±     NaN  ops/ms
-benchmark_4:secondary1    value0    value1    value2    value3    value4  thrpt    1  688.000 ±     NaN  ops/ms
-benchmark_4:secondary2    value0    value1    value2    value3    value4  thrpt    1  237.000 ±     NaN  ops/ms
\ No newline at end of file
+benchmark_4               value0    value1    value2    value3    value4  thrpt       956.000            ops/ms
+benchmark_4:secondary1    value0    value1    value2    value3    value4  thrpt       688.000            ops/ms
+benchmark_4:secondary2    value0    value1    value2    value3    value4  thrpt       237.000            ops/ms
\ No newline at end of file
--- a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.text.ru	Thu Mar 19 18:54:37 2015 +0300
+++ b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.text.ru	Thu Mar 19 22:28:25 2015 +0300
@@ -2,15 +2,15 @@
 benchmark_0               value0    value1    value2    value3    value4  thrpt   14  528,857 ± 278,142  ops/ms
 benchmark_0:secondary1    value0    value1    value2    value3    value4  thrpt   14  549,714 ± 320,227  ops/ms
 benchmark_0:secondary2    value0    value1    value2    value3    value4  thrpt   14  615,500 ± 319,210  ops/ms
-benchmark_1               value0    value1    value2    value3    value4  thrpt    1  439,000 ±     NaN  ops/ms
-benchmark_1:secondary1    value0    value1    value2    value3    value4  thrpt    1  953,000 ±     NaN  ops/ms
-benchmark_1:secondary2    value0    value1    value2    value3    value4  thrpt    1  367,000 ±     NaN  ops/ms
+benchmark_1               value0    value1    value2    value3    value4  thrpt       439,000            ops/ms
+benchmark_1:secondary1    value0    value1    value2    value3    value4  thrpt       953,000            ops/ms
+benchmark_1:secondary2    value0    value1    value2    value3    value4  thrpt       367,000            ops/ms
 benchmark_2               value0    value1    value2    value3    value4  thrpt    9  545,000 ± 553,337  ops/ms
 benchmark_2:secondary1    value0    value1    value2    value3    value4  thrpt    9  434,444 ± 465,183  ops/ms
 benchmark_2:secondary2    value0    value1    value2    value3    value4  thrpt    9  470,333 ± 502,273  ops/ms
 benchmark_3               value0    value1    value2    value3    value4  thrpt   14  417,571 ± 362,814  ops/ms
 benchmark_3:secondary1    value0    value1    value2    value3    value4  thrpt   14  672,214 ± 287,982  ops/ms
 benchmark_3:secondary2    value0    value1    value2    value3    value4  thrpt   14  560,143 ± 289,800  ops/ms
-benchmark_4               value0    value1    value2    value3    value4  thrpt    1  956,000 ±     NaN  ops/ms
-benchmark_4:secondary1    value0    value1    value2    value3    value4  thrpt    1  688,000 ±     NaN  ops/ms
-benchmark_4:secondary2    value0    value1    value2    value3    value4  thrpt    1  237,000 ±     NaN  ops/ms
\ No newline at end of file
+benchmark_4               value0    value1    value2    value3    value4  thrpt       956,000            ops/ms
+benchmark_4:secondary1    value0    value1    value2    value3    value4  thrpt       688,000            ops/ms
+benchmark_4:secondary2    value0    value1    value2    value3    value4  thrpt       237,000            ops/ms
\ No newline at end of file
--- a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.text.us	Thu Mar 19 18:54:37 2015 +0300
+++ b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.text.us	Thu Mar 19 22:28:25 2015 +0300
@@ -2,15 +2,15 @@
 benchmark_0               value0    value1    value2    value3    value4  thrpt   14  528.857 ± 278.142  ops/ms
 benchmark_0:secondary1    value0    value1    value2    value3    value4  thrpt   14  549.714 ± 320.227  ops/ms
 benchmark_0:secondary2    value0    value1    value2    value3    value4  thrpt   14  615.500 ± 319.210  ops/ms
-benchmark_1               value0    value1    value2    value3    value4  thrpt    1  439.000 ±     NaN  ops/ms
-benchmark_1:secondary1    value0    value1    value2    value3    value4  thrpt    1  953.000 ±     NaN  ops/ms
-benchmark_1:secondary2    value0    value1    value2    value3    value4  thrpt    1  367.000 ±     NaN  ops/ms
+benchmark_1               value0    value1    value2    value3    value4  thrpt       439.000            ops/ms
+benchmark_1:secondary1    value0    value1    value2    value3    value4  thrpt       953.000            ops/ms
+benchmark_1:secondary2    value0    value1    value2    value3    value4  thrpt       367.000            ops/ms
 benchmark_2               value0    value1    value2    value3    value4  thrpt    9  545.000 ± 553.337  ops/ms
 benchmark_2:secondary1    value0    value1    value2    value3    value4  thrpt    9  434.444 ± 465.183  ops/ms
 benchmark_2:secondary2    value0    value1    value2    value3    value4  thrpt    9  470.333 ± 502.273  ops/ms
 benchmark_3               value0    value1    value2    value3    value4  thrpt   14  417.571 ± 362.814  ops/ms
 benchmark_3:secondary1    value0    value1    value2    value3    value4  thrpt   14  672.214 ± 287.982  ops/ms
 benchmark_3:secondary2    value0    value1    value2    value3    value4  thrpt   14  560.143 ± 289.800  ops/ms
-benchmark_4               value0    value1    value2    value3    value4  thrpt    1  956.000 ±     NaN  ops/ms
-benchmark_4:secondary1    value0    value1    value2    value3    value4  thrpt    1  688.000 ±     NaN  ops/ms
-benchmark_4:secondary2    value0    value1    value2    value3    value4  thrpt    1  237.000 ±     NaN  ops/ms
\ No newline at end of file
+benchmark_4               value0    value1    value2    value3    value4  thrpt       956.000            ops/ms
+benchmark_4:secondary1    value0    value1    value2    value3    value4  thrpt       688.000            ops/ms
+benchmark_4:secondary2    value0    value1    value2    value3    value4  thrpt       237.000            ops/ms
\ No newline at end of file