changeset 1099:514332583512

7901269: Denser final text report
author shade
date Wed, 21 Jan 2015 23:48:33 +0300
parents 955ecf29330a
children b63eec6fb861
files jmh-core/src/main/java/org/openjdk/jmh/results/format/TextResultFormat.java jmh-core/src/main/java/org/openjdk/jmh/util/ClassUtils.java jmh-core/src/test/java/org/openjdk/jmh/util/TestClassUtils.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 6 files changed, 86 insertions(+), 63 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/results/format/TextResultFormat.java	Wed Jan 21 20:10:48 2015 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/results/format/TextResultFormat.java	Wed Jan 21 23:48:33 2015 +0300
@@ -63,7 +63,6 @@
         for (String prefix : benchPrefixes.values()) {
             nameLen = Math.max(nameLen, prefix.length());
         }
-        nameLen += COLUMN_PAD;
 
         // determine param lengths
         Map<String, Integer> paramLengths = new HashMap<String, Integer>();
@@ -82,7 +81,7 @@
 
         // determine column lengths for other columns
         int modeLen     = "Mode".length();
-        int samplesLen  = "Samples".length();
+        int samplesLen  = "Cnt".length();
         int scoreLen    = "Score".length();
         int scoreErrLen = "Error".length();
         int unitLen     = "Units".length();
@@ -115,7 +114,7 @@
         }
 
         out.print(String.format("%" + modeLen + "s",     "Mode"));
-        out.print(String.format("%" + samplesLen + "s",  "Samples"));
+        out.print(String.format("%" + samplesLen + "s",  "Cnt"));
         out.print(String.format("%" + scoreLen + "s",    "Score"));
         out.print("  ");
         out.print(String.format("%" + scoreErrLen + "s", "Error"));
--- a/jmh-core/src/main/java/org/openjdk/jmh/util/ClassUtils.java	Wed Jan 21 20:10:48 2015 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/util/ClassUtils.java	Wed Jan 21 23:48:33 2015 +0300
@@ -107,33 +107,46 @@
 
         boolean first = true;
 
+        boolean prefixCut = false;
+
         String[] prefix = new String[0];
         for (String s : src) {
             String[] names = s.split("\\.");
 
             if (first) {
-                prefix = names;
+                prefix = new String[names.length];
+
+                int c;
+                for (c = 0; c < names.length; c++) {
+                    if (names[c].toLowerCase().equals(names[c])) {
+                        prefix[c] = names[c];
+                    } else {
+                        break;
+                    }
+                }
+                prefix = Arrays.copyOf(prefix, c);
                 first = false;
                 continue;
             }
 
             int c = 0;
             while (c < Math.min(prefix.length, names.length)) {
-                if (!names[c].equals(prefix[c])) {
+                String n = names[c];
+                String p = prefix[c];
+                if (!n.equals(p) || !n.toLowerCase().equals(n)) {
                     break;
                 }
                 c++;
             }
 
+            if (prefix.length != c) {
+                prefixCut = true;
+            }
             prefix = Arrays.copyOf(prefix, c);
         }
 
         for (int c = 0; c < prefix.length; c++) {
-            if (prefix[c].toLowerCase().equals(prefix[c])) {
-                prefix[c] = String.valueOf(prefix[c].charAt(0));
-            } else {
-                break;
-            }
+            prefix[c] = prefixCut ? String.valueOf(prefix[c].charAt(0)) : "";
         }
 
         Map<String, String> result = new HashMap<String, String>();
@@ -145,7 +158,9 @@
 
             String dense = "";
             for (String n : names) {
-                dense += n + ".";
+                if (!n.isEmpty()) {
+                    dense += n + ".";
+                }
             }
 
             if (dense.endsWith(".")) {
--- a/jmh-core/src/test/java/org/openjdk/jmh/util/TestClassUtils.java	Wed Jan 21 20:10:48 2015 +0300
+++ b/jmh-core/src/test/java/org/openjdk/jmh/util/TestClassUtils.java	Wed Jan 21 23:48:33 2015 +0300
@@ -38,8 +38,8 @@
         List<String> src = Arrays.asList("org.openjdk.benches.ForkJoinTest.test1", "org.openjdk.benches.ForkJoinTest.test2", "org.openjdk.benches.AnotherTest.test0");
         Map<String,String> map = ClassUtils.denseClassNames(src);
 
-        Assert.assertEquals("o.o.b.ForkJoinTest.test1", map.get("org.openjdk.benches.ForkJoinTest.test1"));
-        Assert.assertEquals("o.o.b.ForkJoinTest.test2", map.get("org.openjdk.benches.ForkJoinTest.test2"));
+        Assert.assertEquals("ForkJoinTest.test1", map.get("org.openjdk.benches.ForkJoinTest.test1"));
+        Assert.assertEquals("ForkJoinTest.test2", map.get("org.openjdk.benches.ForkJoinTest.test2"));
     }
 
     @Test
@@ -47,7 +47,7 @@
         List<String> src = Arrays.asList("org.openjdk.benches.ForkJoinTest.test1");
         Map<String,String> map = ClassUtils.denseClassNames(src);
 
-        Assert.assertEquals("o.o.b.ForkJoinTest.test1", map.get("org.openjdk.benches.ForkJoinTest.test1"));
+        Assert.assertEquals("ForkJoinTest.test1", map.get("org.openjdk.benches.ForkJoinTest.test1"));
     }
 
     @Test
@@ -55,7 +55,7 @@
         List<String> src = Arrays.asList("org.openjdk.benches.ForkJoinTest.test1:label1");
         Map<String,String> map = ClassUtils.denseClassNames(src);
 
-        Assert.assertEquals("o.o.b.ForkJoinTest.test1:label1", map.get("org.openjdk.benches.ForkJoinTest.test1:label1"));
+        Assert.assertEquals("ForkJoinTest.test1:label1", map.get("org.openjdk.benches.ForkJoinTest.test1:label1"));
     }
 
     @Test
@@ -68,5 +68,14 @@
         Assert.assertEquals("test.jmh.TestJmhBenchmark", map.get("test.jmh.TestJmhBenchmark"));
     }
 
+    @Test
+    public void testSemiDifferentPackages() {
+        List<String> src = Arrays.asList("com.some.Benchmark", "com.some2.Benchmark2");
+        Map<String,String> map = ClassUtils.denseClassNames(src);
+
+        Assert.assertEquals("c.some.Benchmark", map.get("com.some.Benchmark"));
+        Assert.assertEquals("c.some2.Benchmark2", map.get("com.some2.Benchmark2"));
+    }
+
 
 }
--- a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.text.root	Wed Jan 21 20:10:48 2015 +0300
+++ b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.text.root	Wed Jan 21 23:48:33 2015 +0300
@@ -1,16 +1,16 @@
-Benchmark                 (param0)  (param1)  (param2)  (param3)  (param4)   Mode  Samples    Score     Error   Units
-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_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               (param0)  (param1)  (param2)  (param3)  (param4)   Mode  Cnt    Score     Error   Units
+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_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
--- a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.text.ru	Wed Jan 21 20:10:48 2015 +0300
+++ b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.text.ru	Wed Jan 21 23:48:33 2015 +0300
@@ -1,16 +1,16 @@
-Benchmark                 (param0)  (param1)  (param2)  (param3)  (param4)   Mode  Samples    Score     Error   Units
-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_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               (param0)  (param1)  (param2)  (param3)  (param4)   Mode  Cnt    Score     Error   Units
+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_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
--- a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.text.us	Wed Jan 21 20:10:48 2015 +0300
+++ b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.text.us	Wed Jan 21 23:48:33 2015 +0300
@@ -1,16 +1,16 @@
-Benchmark                 (param0)  (param1)  (param2)  (param3)  (param4)   Mode  Samples    Score     Error   Units
-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_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               (param0)  (param1)  (param2)  (param3)  (param4)   Mode  Cnt    Score     Error   Units
+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_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