changeset 417:cb6358cfb6c5

@Param values should be printed in CSV/SCSV reports as well.
author shade
date Thu, 20 Feb 2014 13:00:38 +0400
parents a3a905ff7a94
children b33c145ad8d8
files jmh-core-it/src/test/java/org/openjdk/jmh/it/params/Shared.java jmh-core/src/main/java/org/openjdk/jmh/output/results/XSVResultFormat.java jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkRecord.java jmh-core/src/test/resources/org/openjdk/jmh/output/results/output-golden.csv jmh-core/src/test/resources/org/openjdk/jmh/output/results/output-golden.scsv
diffstat 5 files changed, 45 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/Shared.java	Wed Feb 19 23:43:49 2014 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/Shared.java	Thu Feb 20 13:00:38 2014 +0400
@@ -37,7 +37,7 @@
     public static void compare(SortedMap<BenchmarkRecord,RunResult> params, int[] xs, String[] ys) {
         Set<String> actualPairs = new HashSet<String>();
         for (BenchmarkRecord br : params.keySet()) {
-            actualPairs.add(br.getActualParams().get("x") + br.getActualParams().get("y"));
+            actualPairs.add(br.getActualParam("x") + br.getActualParam("y"));
         }
 
         for (int x : xs) {
--- a/jmh-core/src/main/java/org/openjdk/jmh/output/results/XSVResultFormat.java	Wed Feb 19 23:43:49 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/output/results/XSVResultFormat.java	Thu Feb 20 13:00:38 2014 +0400
@@ -32,6 +32,8 @@
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Map;
+import java.util.SortedSet;
+import java.util.TreeSet;
 
 class XSVResultFormat implements ResultFormat {
 
@@ -45,6 +47,13 @@
 
     @Override
     public void writeOut(Map<BenchmarkRecord, RunResult> results) {
+        SortedSet<String> params = new TreeSet<String>();
+        for (BenchmarkRecord br : results.keySet()) {
+            if (br.getActualParams() != null) {
+                params.addAll(br.getActualParams().keys());
+            }
+        }
+
         pw.write("\"Benchmark\"");
         pw.write(delimiter);
         pw.write("\"Mode\"");
@@ -58,6 +67,10 @@
         pw.write("\"Mean Error (99.9%)\"");
         pw.write(delimiter);
         pw.write("\"Unit\"");
+        for (String k : params) {
+            pw.write(delimiter);
+            pw.write("\"Param: " + k + "\"");
+        }
         pw.write("\r\n");
 
         for (BenchmarkRecord br : results.keySet()) {
@@ -82,6 +95,17 @@
             pw.write("\"");
             pw.write(runResult.getPrimaryResult().getScoreUnit());
             pw.write("\"");
+
+            for (String p : params) {
+                pw.write(delimiter);
+                pw.write("\"");
+                String v = br.getActualParam(p);
+                if (v != null) {
+                    pw.write(v);
+                }
+                pw.write("\"");
+            }
+
             pw.write("\r\n");
         }
 
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkRecord.java	Wed Feb 19 23:43:49 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkRecord.java	Thu Feb 20 13:00:38 2014 +0400
@@ -147,6 +147,14 @@
         return actualParams;
     }
 
+    public String getActualParam(String key) {
+        if (actualParams != null) {
+            return actualParams.get(key);
+        } else {
+            return null;
+        }
+    }
+
     private int[] convert(String[] ss) {
         int[] arr = new int[ss.length];
         int cnt = 0;
--- a/jmh-core/src/test/resources/org/openjdk/jmh/output/results/output-golden.csv	Wed Feb 19 23:43:49 2014 +0400
+++ b/jmh-core/src/test/resources/org/openjdk/jmh/output/results/output-golden.csv	Thu Feb 20 13:00:38 2014 +0400
@@ -1,6 +1,6 @@
-"Benchmark","Mode","Threads","Samples","Mean","Mean Error (99.9%)","Unit"
-"benchmark_0","avgt",80,14,528.8571428571429,278.1419529743147,"ops/ms"
-"benchmark_1","avgt",900,1,439.0,NaN,"ops/ms"
-"benchmark_2","avgt",466,9,545.0,553.3366994253071,"ops/ms"
-"benchmark_3","avgt",968,14,417.57142857142856,362.81396705929166,"ops/ms"
-"benchmark_4","avgt",739,1,956.0,NaN,"ops/ms"
+"Benchmark","Mode","Threads","Samples","Mean","Mean Error (99.9%)","Unit","Param: param0","Param: param1","Param: param2","Param: param3","Param: param4"
+"benchmark_0","avgt",80,14,528.8571428571429,278.1419529743147,"ops/ms","value0","value1","value2","value3","value4"
+"benchmark_1","avgt",900,1,439.0,NaN,"ops/ms","value0","value1","value2","value3","value4"
+"benchmark_2","avgt",466,9,545.0,553.3366994253071,"ops/ms","value0","value1","value2","value3","value4"
+"benchmark_3","avgt",968,14,417.57142857142856,362.81396705929166,"ops/ms","value0","value1","value2","value3","value4"
+"benchmark_4","avgt",739,1,956.0,NaN,"ops/ms","value0","value1","value2","value3","value4"
\ No newline at end of file
--- a/jmh-core/src/test/resources/org/openjdk/jmh/output/results/output-golden.scsv	Wed Feb 19 23:43:49 2014 +0400
+++ b/jmh-core/src/test/resources/org/openjdk/jmh/output/results/output-golden.scsv	Thu Feb 20 13:00:38 2014 +0400
@@ -1,6 +1,6 @@
-"Benchmark";"Mode";"Threads";"Samples";"Mean";"Mean Error (99.9%)";"Unit"
-"benchmark_0";"avgt";80;14;528.8571428571429;278.1419529743147;"ops/ms"
-"benchmark_1";"avgt";900;1;439.0;NaN;"ops/ms"
-"benchmark_2";"avgt";466;9;545.0;553.3366994253071;"ops/ms"
-"benchmark_3";"avgt";968;14;417.57142857142856;362.81396705929166;"ops/ms"
-"benchmark_4";"avgt";739;1;956.0;NaN;"ops/ms"
\ No newline at end of file
+"Benchmark";"Mode";"Threads";"Samples";"Mean";"Mean Error (99.9%)";"Unit";"Param: param0";"Param: param1";"Param: param2";"Param: param3";"Param: param4"
+"benchmark_0";"avgt";80;14;528.8571428571429;278.1419529743147;"ops/ms";"value0";"value1";"value2";"value3";"value4"
+"benchmark_1";"avgt";900;1;439.0;NaN;"ops/ms";"value0";"value1";"value2";"value3";"value4"
+"benchmark_2";"avgt";466;9;545.0;553.3366994253071;"ops/ms";"value0";"value1";"value2";"value3";"value4"
+"benchmark_3";"avgt";968;14;417.57142857142856;362.81396705929166;"ops/ms";"value0";"value1";"value2";"value3";"value4"
+"benchmark_4";"avgt";739;1;956.0;NaN;"ops/ms";"value0";"value1";"value2";"value3";"value4"
\ No newline at end of file