changeset 160:f75b8c3a1ded

Another touchup in OutputFormat interface.
author shade
date Thu, 29 Aug 2013 17:31:25 +0400
parents 511a26839ce9
children 73c3a6c35b9e
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/BaseRunner.java
diffstat 6 files changed, 31 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/output/format/CsvFormat.java	Thu Aug 29 16:59:21 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/output/format/CsvFormat.java	Thu Aug 29 17:31:25 2013 +0400
@@ -30,7 +30,7 @@
 import org.openjdk.jmh.profile.ProfilerResult;
 import org.openjdk.jmh.runner.BenchmarkRecord;
 import org.openjdk.jmh.runner.parameters.BenchmarkParams;
-import org.openjdk.jmh.runner.parameters.TimeValue;
+import org.openjdk.jmh.runner.parameters.IterationParams;
 
 import java.io.PrintStream;
 import java.util.Collection;
@@ -52,14 +52,14 @@
     }
 
     @Override
-    public void iterationResult(BenchmarkRecord name, int iteration, IterationType type, int thread, IterationResult result, Collection<ProfilerResult> profiles) {
+    public void iterationResult(BenchmarkRecord name, IterationParams params, int iteration, IterationType type, IterationResult result, Collection<ProfilerResult> profiles) {
         if (type != IterationType.MEASUREMENT) return;
 
         out.print(name + DELIMITER + iteration + DELIMITER);
         for (Result r : result.getResult().values()) {
             out.print(convertDouble(r.getScore()) + DELIMITER);
         }
-        out.print(thread + DELIMITER + result.getScoreUnit() + DELIMITER);
+        out.print(params.getThreads() + DELIMITER + result.getScoreUnit() + DELIMITER);
         for (Result r : result.getSubresults().values()) {
             out.print(convertDouble(r.getScore()) + DELIMITER);
         }
@@ -98,7 +98,7 @@
     }
 
     @Override
-    public void iteration(BenchmarkRecord benchmark, int iteration, IterationType type, int threads, TimeValue runTime) {
+    public void iteration(BenchmarkRecord benchmark, IterationParams params, int iteration, IterationType type) {
         // don't print anything
     }
 
@@ -107,7 +107,7 @@
     }
 
     @Override
-    public void detailedResults(BenchmarkRecord name, int iteration, int threads, IterationResult results) {
+    public void detailedResults(BenchmarkRecord name, IterationParams params, int iteration, IterationResult results) {
         int count = 0;
 
         for (Result result : results.getSubresults().values()) {
@@ -117,7 +117,7 @@
         }
 
         // print tail
-        for (int i = count; i < threads; i++) {
+        for (int i = count; i < params.getThreads(); i++) {
             out.print(DELIMITER);
         }
 
--- a/jmh-core/src/main/java/org/openjdk/jmh/output/format/OutputFormat.java	Thu Aug 29 16:59:21 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/output/format/OutputFormat.java	Thu Aug 29 17:31:25 2013 +0400
@@ -29,7 +29,7 @@
 import org.openjdk.jmh.profile.ProfilerResult;
 import org.openjdk.jmh.runner.BenchmarkRecord;
 import org.openjdk.jmh.runner.parameters.BenchmarkParams;
-import org.openjdk.jmh.runner.parameters.TimeValue;
+import org.openjdk.jmh.runner.parameters.IterationParams;
 
 import java.io.IOException;
 import java.util.Collection;
@@ -48,22 +48,21 @@
      * Format for iteration start.
      *
      * @param benchmark benchmark name
+     * @param params
      * @param iteration iteration-number
-     * @param threads threads to run
-     * @param runTime time to spend per iteration
      */
-    public void iteration(BenchmarkRecord benchmark, int iteration, IterationType type, int threads, TimeValue runTime);
+    public void iteration(BenchmarkRecord benchmark, IterationParams params, int iteration, IterationType type);
 
     /**
      * Format for end-of-iteration.
      *
      * @param name      name of benchmark
+     * @param params
      * @param iteration iteration-number
-     * @param thread    amount of threads used
      * @param result    result of iteration
      * @param profiles  profiler results
      */
-    public void iterationResult(BenchmarkRecord name, int iteration, IterationType type, int thread, IterationResult result, Collection<ProfilerResult> profiles);
+    public void iterationResult(BenchmarkRecord name, IterationParams params, int iteration, IterationType type, IterationResult result, Collection<ProfilerResult> profiles);
 
     /**
      * Format for start-of-benchmark output.
@@ -94,11 +93,11 @@
      * Format for detailed results output.
      *
      * @param name      benchmark name
+     * @param params
      * @param iteration iteration number
-     * @param threads   thread count
      * @param results   AggregatedResults with detailed run results
      */
-    public void detailedResults(BenchmarkRecord name, int iteration, int threads, IterationResult results);
+    public void detailedResults(BenchmarkRecord name, IterationParams params, int iteration, IterationResult results);
 
     /* ------------- SPECIAL TRACING METHODS -------------------- */
 
--- a/jmh-core/src/main/java/org/openjdk/jmh/output/format/PrettyPrintFormat.java	Thu Aug 29 16:59:21 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/output/format/PrettyPrintFormat.java	Thu Aug 29 17:31:25 2013 +0400
@@ -30,7 +30,7 @@
 import org.openjdk.jmh.profile.ProfilerResult;
 import org.openjdk.jmh.runner.BenchmarkRecord;
 import org.openjdk.jmh.runner.parameters.BenchmarkParams;
-import org.openjdk.jmh.runner.parameters.TimeValue;
+import org.openjdk.jmh.runner.parameters.IterationParams;
 import org.openjdk.jmh.util.internal.Multimap;
 import org.openjdk.jmh.util.internal.TreeMultimap;
 
@@ -52,7 +52,7 @@
     }
 
     @Override
-    public void iterationResult(BenchmarkRecord name, int iteration, IterationType type, int thread, IterationResult result, Collection<ProfilerResult> profiles) {
+    public void iterationResult(BenchmarkRecord name, IterationParams params, int iteration, IterationType type, IterationResult result, Collection<ProfilerResult> profiles) {
         out.print(String.format("%s", result.toPrintable()));
 
         // also print out profiler information
@@ -136,15 +136,15 @@
     }
 
     @Override
-    public void iteration(BenchmarkRecord benchmark, int iteration, IterationType type, int threads, TimeValue timeValue) {
+    public void iteration(BenchmarkRecord benchmark, IterationParams params, int iteration, IterationType type) {
         switch (type) {
             case WARMUP:
                 out.print(String.format("# Warmup Iteration %3d (%s in %d %s): ", iteration,
-                        timeValue, threads, getThreadsString(threads)));
+                        params.getTime(), params.getThreads(), getThreadsString(params.getThreads())));
                 break;
             case MEASUREMENT:
                 out.print(String.format("Iteration %3d (%s in %d %s): ", iteration,
-                        timeValue, threads, getThreadsString(threads)));
+                        params.getTime(), params.getThreads(), getThreadsString(params.getThreads())));
                 break;
             default:
                 throw new IllegalStateException("Unknown iteration type: " + type);
@@ -153,7 +153,7 @@
     }
 
     @Override
-    public void detailedResults(BenchmarkRecord name, int iteration, int threads, IterationResult results) {
+    public void detailedResults(BenchmarkRecord name, IterationParams params, int iteration, IterationResult results) {
         out.print("Results per thread: [");
 
         boolean first = true;
--- a/jmh-core/src/main/java/org/openjdk/jmh/output/format/SilentFormat.java	Thu Aug 29 16:59:21 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/output/format/SilentFormat.java	Thu Aug 29 17:31:25 2013 +0400
@@ -29,7 +29,7 @@
 import org.openjdk.jmh.profile.ProfilerResult;
 import org.openjdk.jmh.runner.BenchmarkRecord;
 import org.openjdk.jmh.runner.parameters.BenchmarkParams;
-import org.openjdk.jmh.runner.parameters.TimeValue;
+import org.openjdk.jmh.runner.parameters.IterationParams;
 
 import java.io.PrintStream;
 import java.util.Collection;
@@ -64,17 +64,17 @@
     }
 
     @Override
-    public void detailedResults(BenchmarkRecord name, int iteration, int threads, IterationResult results) {
+    public void detailedResults(BenchmarkRecord name, IterationParams params, int iteration, IterationResult results) {
 
     }
 
     @Override
-    public void iteration(BenchmarkRecord benchmark, int iteration, IterationType type, int threads, TimeValue runTime) {
+    public void iteration(BenchmarkRecord benchmark, IterationParams params, int iteration, IterationType type) {
 
     }
 
     @Override
-    public void iterationResult(BenchmarkRecord name, int iteration, IterationType type, int thread, IterationResult result, Collection<ProfilerResult> profiles) {
+    public void iterationResult(BenchmarkRecord name, IterationParams params, int iteration, IterationType type, IterationResult result, Collection<ProfilerResult> profiles) {
 
     }
 
--- a/jmh-core/src/main/java/org/openjdk/jmh/output/format/TextReportFormat.java	Thu Aug 29 16:59:21 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/output/format/TextReportFormat.java	Thu Aug 29 17:31:25 2013 +0400
@@ -68,10 +68,10 @@
     }
 
     @Override
-    public void iterationResult(BenchmarkRecord name, int iteration, IterationType type, int thread, IterationResult result, Collection<ProfilerResult> profiles) {
-        super.iterationResult(name, iteration, type, thread, result, profiles);
+    public void iterationResult(BenchmarkRecord name, IterationParams params, int iteration, IterationType type, IterationResult result, Collection<ProfilerResult> profiles) {
+        super.iterationResult(name, params, iteration, type, result, profiles);
         if (type == IterationType.MEASUREMENT) {
-            benchmarkResults.put(new BenchmarkIdentifier(name, thread), result);
+            benchmarkResults.put(new BenchmarkIdentifier(name, params.getThreads()), result);
         }
     }
 
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java	Thu Aug 29 16:59:21 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java	Thu Aug 29 17:31:25 2013 +0400
@@ -97,11 +97,11 @@
                 out.verbosePrintln("System.gc() executed");
             }
 
-            out.iteration(handler.getBenchmark(), i, IterationType.WARMUP, wp.getThreads(), wp.getTime());
+            out.iteration(handler.getBenchmark(), wp, i, IterationType.WARMUP);
             boolean isLastIteration = (executionParams.getIteration().getCount() == 0);
             IterationData iterData = handler.runIteration(wp, isLastIteration);
             IterationResult iterResult = new IterationResult(iterData.getRawResults());
-            out.iterationResult(handler.getBenchmark(), i, IterationType.WARMUP, options.getThreads(), iterResult, iterData.getProfilerResults());
+            out.iterationResult(handler.getBenchmark(), wp, i, IterationType.WARMUP, iterResult, iterData.getProfilerResults());
         }
 
         // measurement
@@ -113,7 +113,7 @@
             }
 
             // run benchmark iteration
-            out.iteration(handler.getBenchmark(), i, IterationType.MEASUREMENT, mp.getThreads(), mp.getTime());
+            out.iteration(handler.getBenchmark(), mp, i, IterationType.MEASUREMENT);
 
             boolean isLastIteration = (i == mp.getCount());
             IterationData iterData = handler.runIteration(mp, isLastIteration);
@@ -123,10 +123,10 @@
                 out.println("WARNING: No results returned, benchmark payload threw exception?");
             } else {
                 IterationResult iterResult = new IterationResult(iterData.getRawResults());
-                out.iterationResult(handler.getBenchmark(), i, IterationType.MEASUREMENT, mp.getThreads(), iterResult, iterData.getProfilerResults());
+                out.iterationResult(handler.getBenchmark(), mp, i, IterationType.MEASUREMENT, iterResult, iterData.getProfilerResults());
 
                 if (options.shouldOutputDetailedResults()) {
-                    out.detailedResults(handler.getBenchmark(), i, mp.getThreads(), iterResult);
+                    out.detailedResults(handler.getBenchmark(), mp, i, iterResult);
                 }
 
                 allResults.add(iterData);