changeset 136:7ba43108f829

Enforce OutputFormat,{start|end}Run contract.
author shade
date Fri, 23 Aug 2013 12:16:15 +0400
parents 309279f710b7
children 0cea178f3eb4
files jmh-core/src/main/java/org/openjdk/jmh/output/format/CsvFormat.java jmh-core/src/main/java/org/openjdk/jmh/output/format/OutputFormat.java jmh-core/src/main/java/org/openjdk/jmh/output/format/PrettyPrintFormat.java jmh-core/src/main/java/org/openjdk/jmh/output/format/SilentFormat.java jmh-core/src/main/java/org/openjdk/jmh/output/format/TextReportFormat.java jmh-core/src/main/java/org/openjdk/jmh/runner/ForkedRunner.java jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java
diffstat 7 files changed, 18 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/output/format/CsvFormat.java	Wed Aug 21 21:26:58 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/output/format/CsvFormat.java	Fri Aug 23 12:16:15 2013 +0400
@@ -88,12 +88,12 @@
     }
 
     @Override
-    public void startRun(String message) {
+    public void startRun() {
         // don't print anything
     }
 
     @Override
-    public void endRun(String message) {
+    public void endRun() {
         // don't print anything
     }
 
--- a/jmh-core/src/main/java/org/openjdk/jmh/output/format/OutputFormat.java	Wed Aug 21 21:26:58 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/output/format/OutputFormat.java	Fri Aug 23 12:16:15 2013 +0400
@@ -82,17 +82,13 @@
 
     /**
      * Format for start-of-benchmark output.
-     *
-     * @param message message to dump
      */
-    public void startRun(String message);
+    public void startRun();
 
     /**
      * Format for end-of-benchmark.
-     *
-     * @param message message to dump
      */
-    public void endRun(String message);
+    public void endRun();
 
     /**
      * Format for detailed results output.
--- a/jmh-core/src/main/java/org/openjdk/jmh/output/format/PrettyPrintFormat.java	Wed Aug 21 21:26:58 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/output/format/PrettyPrintFormat.java	Fri Aug 23 12:16:15 2013 +0400
@@ -111,12 +111,12 @@
     }
 
     @Override
-    public void startRun(String message) {
-        out.println("# " + message);
+    public void startRun() {
+        // do nothing
     }
 
     @Override
-    public void endRun(String message) {
+    public void endRun() {
         for (BenchmarkRecord key : benchmarkResults.keys()) {
             Collection<RunResult> forkedResults = benchmarkResults.get(key);
             if (forkedResults.size() > 1) {
--- a/jmh-core/src/main/java/org/openjdk/jmh/output/format/SilentFormat.java	Wed Aug 21 21:26:58 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/output/format/SilentFormat.java	Fri Aug 23 12:16:15 2013 +0400
@@ -46,11 +46,11 @@
     }
 
     @Override
-    public void startRun(String message) {
+    public void startRun() {
     }
 
     @Override
-    public void endRun(String message) {
+    public void endRun() {
     }
 
     @Override
--- a/jmh-core/src/main/java/org/openjdk/jmh/output/format/TextReportFormat.java	Wed Aug 21 21:26:58 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/output/format/TextReportFormat.java	Fri Aug 23 12:16:15 2013 +0400
@@ -76,8 +76,8 @@
     }
 
     @Override
-    public void endRun(String message) {
-        super.endRun(null);
+    public void endRun() {
+        super.endRun();
 
         // generate the full report
         //
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/ForkedRunner.java	Wed Aug 21 21:26:58 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/ForkedRunner.java	Fri Aug 23 12:16:15 2013 +0400
@@ -48,9 +48,9 @@
             out.println("Benchmarks: ");
             out.println(benchmark.getUsername());
         }
-        out.startRun("Measurement Section");
+        out.startRun();
         runBenchmark(benchmark, true, true);
-        out.endRun(null);
+        out.endRun();
         out.flush();
         out.close();
     }
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java	Wed Aug 21 21:26:58 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java	Fri Aug 23 12:16:15 2013 +0400
@@ -202,9 +202,7 @@
      * @param list
      */
     private void runBulkWarmupBenchmarks(Set<BenchmarkRecord> benchmarks, MicroBenchmarkList list) {
-        // Attention: Here is violation of out.startRun/endRun contract,
-        // but because of such code was done before me,
-        // I won't touch this in order do not crash output parsers. (SK)
+        out.startRun();
 
         // list of micros executed before iteration
         Set<BenchmarkRecord> warmupMicros = new TreeSet<BenchmarkRecord>();
@@ -226,19 +224,17 @@
             // during measurement iteration causing a performance shift or simply
             // increased variance.
             // currently valid only for non-external JVM runs
-            out.startRun("Warmup Section");
+
             for (BenchmarkRecord benchmark : warmupMicros) {
                 runBenchmark(benchmark, true, false);
             }
-            out.endRun(null);
         }
         // run microbenchmarks
         //
-        out.startRun("Measurement Section");
         for (BenchmarkRecord benchmark : benchmarks) {
             runBenchmark(benchmark, false, true);
         }
-        out.endRun(null);
+        out.endRun();
     }
 
     private int decideForks(int optionForks, int benchForks) {
@@ -265,7 +261,7 @@
         Set<BenchmarkRecord> embedded = new TreeSet<BenchmarkRecord>();
         Set<BenchmarkRecord> forked = new TreeSet<BenchmarkRecord>();
 
-        out.startRun("Measurement Section");
+        out.startRun();
         for (BenchmarkRecord benchmark : benchmarks) {
             int f = decideForks(options.getForkCount(), benchForks(benchmark));
             if (f > 0) {
@@ -280,7 +276,7 @@
         }
 
         runSeparate(forked);
-        out.endRun(null);
+        out.endRun();
     }
 
     private void runSeparate(Set<BenchmarkRecord> benchmarksToFork) {