changeset 1019:1a4b13657050

7901061: Add result format suffix to result files
author shade
date Fri, 10 Oct 2014 18:58:28 +0400
parents 9c1834169bb1
children af27f02e778a
files jmh-core/src/main/java/org/openjdk/jmh/runner/Defaults.java jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java
diffstat 2 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Defaults.java	Fri Oct 10 18:05:59 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Defaults.java	Fri Oct 10 18:58:28 2014 +0400
@@ -113,9 +113,9 @@
     public static final ResultFormatType RESULT_FORMAT = ResultFormatType.CSV;
 
     /**
-     * Default location of result file.
+     * Default prefix of the result file.
      */
-    public static final String RESULT_FILE = "jmh.out";
+    public static final String RESULT_FILE_PREFIX = "jmh-result";
 
     /**
      * Default {@link org.openjdk.jmh.runner.options.WarmupMode}.
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java	Fri Oct 10 18:05:59 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java	Fri Oct 10 18:58:28 2014 +0400
@@ -229,7 +229,8 @@
         // and prepare to write it out after the run.
         String resultFile = null;
         if (options.getResult().hasValue() || options.getResultFormat().hasValue()) {
-            resultFile = options.getResult().orElse(Defaults.RESULT_FILE);
+            resultFile = options.getResult().orElse(Defaults.RESULT_FILE_PREFIX + "."
+                    + options.getResultFormat().orElse(Defaults.RESULT_FORMAT)).toLowerCase();
             try {
                 FileUtils.touch(resultFile);
             } catch (IOException e) {
@@ -296,17 +297,20 @@
 
         Collection<RunResult> results = runBenchmarks(benchmarks);
 
-        out.flush();
-        out.close();
-
         // If user requested the result file, write it out.
         if (resultFile != null) {
             ResultFormatFactory.getInstance(
                         options.getResultFormat().orElse(Defaults.RESULT_FORMAT),
                         resultFile
             ).writeOut(results);
+
+            out.println("");
+            out.println("Benchmark result is saved to " + resultFile);
         }
 
+        out.flush();
+        out.close();
+
         return results;
     }