changeset 422:98267672b30d

BenchmarkRecord.getActualParams() should always be non-null.
author shade
date Fri, 21 Feb 2014 19:16:25 +0400
parents f5a62e773b69
children 79b00b6dbc75
files jmh-core/src/main/java/org/openjdk/jmh/output/format/TextReportFormat.java jmh-core/src/main/java/org/openjdk/jmh/output/results/XSVResultFormat.java jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkRecord.java
diffstat 3 files changed, 10 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/output/format/TextReportFormat.java	Thu Feb 20 16:57:27 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/output/format/TextReportFormat.java	Fri Feb 21 19:16:25 2014 +0400
@@ -67,7 +67,7 @@
         out.println("# Threads: " + mbParams.getThreads() + " " + getThreadsString(mbParams.getThreads()) + (mbParams.shouldSynchIterations() ? ", will synchronize iterations" : ""));
         out.println("# Benchmark mode: " + name.getMode().longLabel());
         out.println("# Benchmark: " + name.getUsername());
-        if (name.getActualParams() != null) {
+        if (!name.getActualParams().isEmpty()) {
             out.println("# Parameters: " + name.getActualParams());
         }
     }
@@ -182,15 +182,13 @@
         Map<String, Integer> paramLengths = new HashMap<String, Integer>();
         SortedSet<String> params = new TreeSet<String>();
         for (BenchmarkRecord br : runResults.keySet()) {
-            if (br.getActualParams() != null) {
-                for (String k : br.getActualParams().keys()) {
-                    params.add(k);
-                    Integer len = paramLengths.get(k);
-                    if (len == null) {
-                        len = ("(" + k + ")").length();
-                    }
-                    paramLengths.put(k, Math.max(len, br.getActualParam(k).length()));
+            for (String k : br.getActualParams().keys()) {
+                params.add(k);
+                Integer len = paramLengths.get(k);
+                if (len == null) {
+                    len = ("(" + k + ")").length();
                 }
+                paramLengths.put(k, Math.max(len, br.getActualParam(k).length()));
             }
         }
 
--- a/jmh-core/src/main/java/org/openjdk/jmh/output/results/XSVResultFormat.java	Thu Feb 20 16:57:27 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/output/results/XSVResultFormat.java	Fri Feb 21 19:16:25 2014 +0400
@@ -27,9 +27,6 @@
 import org.openjdk.jmh.logic.results.RunResult;
 import org.openjdk.jmh.runner.BenchmarkRecord;
 
-import java.io.BufferedWriter;
-import java.io.FileWriter;
-import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Map;
 import java.util.SortedSet;
@@ -49,9 +46,7 @@
     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());
-            }
+            params.addAll(br.getActualParams().keys());
         }
 
         pw.write("\"Benchmark\"");
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkRecord.java	Thu Feb 20 16:57:27 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkRecord.java	Fri Feb 21 19:16:25 2014 +0400
@@ -81,6 +81,7 @@
         this.jvmArgsPrepend = jvmArgsPrepend;
         this.jvmArgsAppend = jvmArgsAppend;
         this.params = params;
+        this.actualParams = new ActualParams();
     }
 
     public BenchmarkRecord(String line) {
@@ -90,6 +91,7 @@
             throw new IllegalStateException("Mismatched format for the line: " + line);
         }
 
+        this.actualParams = new ActualParams();
         this.userName = args[0].trim();
         this.generatedName = args[1].trim();
         this.mode = Mode.deepValueOf(args[2].trim());