changeset 110:ec78e0017c10

Cleanup: rename outputHandler and all it's usages.
author shade
date Mon, 12 Aug 2013 13:12:32 +0400
parents b12e1c6dcd50
children 8349e46230d0
files jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java jmh-core/src/main/java/org/openjdk/jmh/runner/ForkedRunner.java jmh-core/src/main/java/org/openjdk/jmh/runner/MicroBenchmarkHandlers.java jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java
diffstat 4 files changed, 58 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java	Mon Aug 12 13:01:43 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java	Mon Aug 12 13:12:32 2013 +0400
@@ -53,11 +53,11 @@
     /** Class holding all our runtime options/arguments */
     private final BaseOptions options;
 
-    protected final OutputFormat outputHandler;
+    protected final OutputFormat out;
 
     public BaseRunner(BaseOptions options, OutputFormat handler) {
         this.options = options;
-        this.outputHandler = handler;
+        this.out = handler;
     }
 
     /**
@@ -72,9 +72,9 @@
             Method method = MicroBenchmarkHandlers.findBenchmarkMethod(clazz, benchmark.generatedMethod());
 
             MicroBenchmarkParameters executionParams = MicroBenchmarkParametersFactory.makeParams(options, benchmark, method);
-            MicroBenchmarkHandler handler = MicroBenchmarkHandlers.getInstance(outputHandler, benchmark, clazz, method, executionParams, options);
+            MicroBenchmarkHandler handler = MicroBenchmarkHandlers.getInstance(out, benchmark, clazz, method, executionParams, options);
 
-            outputHandler.startBenchmark(handler.getBenchmark(), executionParams, this.options.isVerbose());
+            out.startBenchmark(handler.getBenchmark(), executionParams, this.options.isVerbose());
 
             int iteration = 0;
             final Collection<ThreadIterationParams> threadIterationSequence = executionParams.getThreadIterationSequence();
@@ -93,13 +93,13 @@
             // only print end-of-run output if we have actual results
             if (!allResults.isEmpty()) {
                 RunResult result = aggregateIterationData(allResults);
-                outputHandler.endBenchmark(handler.getBenchmark(), result);
+                out.endBenchmark(handler.getBenchmark(), result);
             }
 
             handler.shutdown();
 
         } catch (Throwable ex) {
-            outputHandler.exception(ex);
+            out.exception(ex);
             if (this.options.shouldFailOnError()) {
                 throw new IllegalStateException(ex.getMessage(), ex);
             }
@@ -115,29 +115,29 @@
         for (int i = 1; i <= tip.getCount(); i++) {
             // will run system gc if we should
             if (runSystemGC()) {
-                outputHandler.verbosePrintln("System.gc() executed");
+                out.verbosePrintln("System.gc() executed");
             }
 
             // run benchmark iteration
-            outputHandler.iteration(handler.getBenchmark(), startIterNum + i, tip.getThreads(), tip.getTime());
+            out.iteration(handler.getBenchmark(), startIterNum + i, tip.getThreads(), tip.getTime());
 
             boolean isLastIteration = (i == tip.getCount());
             IterationData iterData = handler.runIteration(tip.getThreads(), tip.getTime(), isLastIteration);
 
             // might get an exception above, in which case the results list will be empty
             if (iterData.isResultsEmpty()) {
-                outputHandler.println("WARNING: No results returned, benchmark payload threw exception?");
+                out.println("WARNING: No results returned, benchmark payload threw exception?");
             } else {
                 // non-empty list => output and aggregate results
                 results.add(iterData);
 
                 // print out score for this iteration
-                outputHandler.iterationResult(handler.getBenchmark(), startIterNum + i, tip.getThreads(), iterData.getAggregatedResult(), iterData.getProfilerResults());
+                out.iterationResult(handler.getBenchmark(), startIterNum + i, tip.getThreads(), iterData.getAggregatedResult(), iterData.getProfilerResults());
 
                 // detailed output
                 if (showDetailedResults) {
                     // print (or not) detailed per-thread results
-                    outputHandler.detailedResults(handler.getBenchmark(), startIterNum + i, tip.getThreads(), iterData.getAggregatedResult());
+                    out.detailedResults(handler.getBenchmark(), startIterNum + i, tip.getThreads(), iterData.getAggregatedResult());
                 }
 
             }
@@ -148,7 +148,7 @@
             // if threads and the next iteration will change the count,
             // OR if we're finished iterating
             RunResult aggregatedResult = aggregateIterationData(results);
-            outputHandler.threadSubStatistics(handler.getBenchmark(), tip.getThreads(), aggregatedResult);
+            out.threadSubStatistics(handler.getBenchmark(), tip.getThreads(), aggregatedResult);
         }
         return results;
     }
@@ -172,13 +172,13 @@
         for (int i = 1; i <= warmup.getCount(); i++) {
             // will run system gc if we should
             if (runSystemGC()) {
-                outputHandler.verbosePrintln("System.gc() executed");
+                out.verbosePrintln("System.gc() executed");
             }
 
-            outputHandler.warmupIteration(handler.getBenchmark(), i, warmup.getThreads(), warmup.getTime());
+            out.warmupIteration(handler.getBenchmark(), i, warmup.getThreads(), warmup.getTime());
             boolean isLastIteration = false; // warmup is never the last iteration
             IterationData iterData = handler.runIteration(warmup.getThreads(), warmup.getTime(), isLastIteration).setWarmup();
-            outputHandler.warmupIterationResult(handler.getBenchmark(), i, warmup.getThreads(), iterData.getAggregatedResult());
+            out.warmupIterationResult(handler.getBenchmark(), i, warmup.getThreads(), iterData.getAggregatedResult());
         }
     }
 
@@ -210,7 +210,7 @@
             final int MAX_WAIT_MSEC = 20 * 1000;
 
             if (enabledBeans.isEmpty()) {
-                outputHandler.println("WARNING: MXBeans can not report GC info. System.gc() invoked, pessimistically waiting " + MAX_WAIT_MSEC + " msecs");
+                out.println("WARNING: MXBeans can not report GC info. System.gc() invoked, pessimistically waiting " + MAX_WAIT_MSEC + " msecs");
                 try {
                     TimeUnit.MILLISECONDS.sleep(MAX_WAIT_MSEC);
                 } catch (InterruptedException e) {
@@ -237,7 +237,7 @@
                 }
             }
 
-            outputHandler.println("WARNING: System.gc() was invoked but couldn't detect a GC occuring, is System.gc() disabled?");
+            out.println("WARNING: System.gc() was invoked but couldn't detect a GC occuring, is System.gc() disabled?");
             return false;
         }
         return false;
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/ForkedRunner.java	Mon Aug 12 13:01:43 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/ForkedRunner.java	Mon Aug 12 13:12:32 2013 +0400
@@ -45,18 +45,18 @@
         // expect the tuple from the parent process
         BenchmarkRecord benchmark = new BenchmarkRecord(options.getBenchmark());
         if (options.isVerbose()) {
-            outputHandler.println("Benchmarks: ");
-            outputHandler.println(benchmark.getUsername());
+            out.println("Benchmarks: ");
+            out.println(benchmark.getUsername());
         }
         runForkedBenchmarks(benchmark);
-        outputHandler.flush();
-        outputHandler.close();
+        out.flush();
+        out.close();
     }
 
     private void runForkedBenchmarks(BenchmarkRecord benchmark) {
-        outputHandler.startRun("Measurement Section");
+        out.startRun("Measurement Section");
         runClassicBenchmark(benchmark);
-        outputHandler.endRun(null);
+        out.endRun(null);
     }
 
 }
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/MicroBenchmarkHandlers.java	Mon Aug 12 13:01:43 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/MicroBenchmarkHandlers.java	Mon Aug 12 13:12:32 2013 +0400
@@ -69,8 +69,8 @@
         return method;
     }
 
-    public static MicroBenchmarkHandler getInstance(OutputFormat outputHandler, BenchmarkRecord microbenchmark, Class<?> clazz, Method method, MicroBenchmarkParameters executionParams, BaseOptions options) {
-        return new LoopMicroBenchmarkHandler(outputHandler, microbenchmark, clazz, method, options, executionParams);
+    public static MicroBenchmarkHandler getInstance(OutputFormat out, BenchmarkRecord microbenchmark, Class<?> clazz, Method method, MicroBenchmarkParameters executionParams, BaseOptions options) {
+        return new LoopMicroBenchmarkHandler(out, microbenchmark, clazz, method, options, executionParams);
     }
 
     /**
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java	Mon Aug 12 13:01:43 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java	Mon Aug 12 13:12:32 2013 +0400
@@ -74,7 +74,7 @@
      * @param options
      */
     public Runner(HarnessOptions options) {
-        super(options, createOutputHandler(options));
+        super(options, createOutputFormat(options));
         this.options = options;
     }
 
@@ -109,10 +109,10 @@
         }
     }
 
-    /** Setup helper method, creates OutputHandler according to argv options. */
-    public static OutputFormat createOutputHandler(HarnessOptions options) {
+    /** Setup helper method, creates OutputFormat according to argv options. */
+    public static OutputFormat createOutputFormat(HarnessOptions options) {
         PrintStream out;
-        // setup OutputHandler singleton
+        // setup OutputFormat singleton
         if (options.getOutput() == null) {
             out = System.out;
         } else {
@@ -134,24 +134,24 @@
 
         // get a list of benchmarks
         if (options.getRegexps().isEmpty()) {
-            outputHandler.println("No regexp to match against benchmarks was given. Use -h for help or \".*\" for every benchmark.");
-            outputHandler.flush();
+            out.println("No regexp to match against benchmarks was given. Use -h for help or \".*\" for every benchmark.");
+            out.flush();
             benchmarks = Collections.emptySet();
         } else {
-            benchmarks = list.find(outputHandler, options.getRegexps(), options.getExcludes());
+            benchmarks = list.find(out, options.getRegexps(), options.getExcludes());
         }
 
         if (benchmarks.isEmpty() && !options.getRegexps().isEmpty()) {
-            outputHandler.println("No matching benchmarks. Miss-spelled regexp? Use -v for verbose output.");
-            outputHandler.flush();
+            out.println("No matching benchmarks. Miss-spelled regexp? Use -v for verbose output.");
+            out.flush();
         }
 
         if (options.shouldList() || options.isVerbose()) {
-            outputHandler.println("Benchmarks: ");
+            out.println("Benchmarks: ");
 
             // list microbenchmarks if -l and/or -v
             for (BenchmarkRecord benchmark : benchmarks) {
-                outputHandler.println(benchmark.getUsername());
+                out.println(benchmark.getUsername());
             }
         }
 
@@ -203,8 +203,8 @@
             }
         }
 
-        outputHandler.flush();
-        outputHandler.close();
+        out.flush();
+        out.close();
     }
 
     /**
@@ -215,7 +215,7 @@
      * @param list
      */
     private void runBulkWarmupBenchmarks(Set<BenchmarkRecord> benchmarks, MicroBenchmarkList list) {
-        // Attention: Here is violation of outputHandler.startRun/endRun contract,
+        // 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)
 
@@ -224,7 +224,7 @@
 
         List<String> warmupMicrosRegexp = options.getWarmupMicros();
         if (warmupMicrosRegexp != null && !warmupMicrosRegexp.isEmpty()) {
-            warmupMicros.addAll(list.find(outputHandler, warmupMicrosRegexp, Collections.<String>emptyList()));
+            warmupMicros.addAll(list.find(out, warmupMicrosRegexp, Collections.<String>emptyList()));
         }
         if (options.getWarmupMode() == HarnessOptions.WarmupMode.BEFOREANY) {
             warmupMicros.addAll(benchmarks);
@@ -239,19 +239,19 @@
             // during measurement iteration causing a performance shift or simply
             // increased variance.
             // currently valid only for non-external JVM runs
-            outputHandler.startRun("Warmup Section");
+            out.startRun("Warmup Section");
             for (BenchmarkRecord benchmark : warmupMicros) {
                 runBulkWarmupModeMicroBenchmark(benchmark, true);
             }
-            outputHandler.endRun(null);
+            out.endRun(null);
         }
         // run microbenchmarks
         //
-        outputHandler.startRun("Measurement Section");
+        out.startRun("Measurement Section");
         for (BenchmarkRecord benchmark : benchmarks) {
             runBulkWarmupModeMicroBenchmark(benchmark, false);
         }
-        outputHandler.endRun(null);
+        out.endRun(null);
     }
 
     private int decideForks(int optionForks, int benchForks) {
@@ -278,7 +278,7 @@
         Set<BenchmarkRecord> embedded = new TreeSet<BenchmarkRecord>();
         Set<BenchmarkRecord> forked = new TreeSet<BenchmarkRecord>();
 
-        outputHandler.startRun("Measurement Section");
+        out.startRun("Measurement Section");
         for (BenchmarkRecord benchmark : benchmarks) {
             int f = decideForks(options.getForkCount(), benchForks(benchmark));
             if (f > 0) {
@@ -293,13 +293,13 @@
         }
 
         runSeparate(forked);
-        outputHandler.endRun(null);
+        out.endRun(null);
     }
 
     private void runSeparate(Set<BenchmarkRecord> benchmarksToFork) {
         BinaryOutputFormatReader reader = null;
         try {
-            reader = new BinaryOutputFormatReader(outputHandler);
+            reader = new BinaryOutputFormatReader(out);
             for (BenchmarkRecord benchmark : benchmarksToFork) {
                 runSeparateMicroBenchmark(reader, benchmark, reader.getHost(), reader.getPort());
             }
@@ -361,18 +361,18 @@
         if (warmupForkCount > 0) {
             String[] warmupForkCheat = concat(commandString, new String[]{"-wi", "1", "-i", "0"});
             if (warmupForkCount == 1) {
-                outputHandler.verbosePrintln("Warmup forking using command: " + Arrays.toString(warmupForkCheat));
+                out.verbosePrintln("Warmup forking using command: " + Arrays.toString(warmupForkCheat));
             } else {
-                outputHandler.verbosePrintln("Warmup forking " + warmupForkCount + " times using command: " + Arrays.toString(warmupForkCheat));
+                out.verbosePrintln("Warmup forking " + warmupForkCount + " times using command: " + Arrays.toString(warmupForkCheat));
             }
             for (int i = 0; i < warmupForkCount; i++) {
                 doFork(reader, warmupForkCheat);
             }
         }
         if (forkCount == 1) {
-            outputHandler.verbosePrintln("Forking using command: " + Arrays.toString(commandString));
+            out.verbosePrintln("Forking using command: " + Arrays.toString(commandString));
         } else {
-            outputHandler.verbosePrintln("Forking " + forkCount + " times using command: " + Arrays.toString(commandString));
+            out.verbosePrintln("Forking " + forkCount + " times using command: " + Arrays.toString(commandString));
         }
         for (int i = 0; i < forkCount; i++) { // TODO should we report fork number somehow?
             doFork(reader, commandString);
@@ -407,16 +407,16 @@
             reader.waitFinish();
 
             if (ecode != 0) {
-                outputHandler.println("WARNING: Forked process returned code: " + ecode);
+                out.println("WARNING: Forked process returned code: " + ecode);
                 if (options.shouldFailOnError()) {
                     throw new IllegalStateException("WARNING: Forked process returned code: " + ecode);
                 }
             }
 
         } catch (IOException ex) {
-            outputHandler.exception(ex);
+            out.exception(ex);
         } catch (InterruptedException ex) {
-            outputHandler.exception(ex);
+            out.exception(ex);
         }
     }
 
@@ -437,11 +437,11 @@
             Method method = MicroBenchmarkHandlers.findBenchmarkMethod(clazz, methodName);
 
             MicroBenchmarkParameters executionParams = MicroBenchmarkParametersFactory.makeParams(options, benchmark, method);
-            MicroBenchmarkHandler handler = MicroBenchmarkHandlers.getInstance(outputHandler, benchmark, clazz, method, executionParams, options);
+            MicroBenchmarkHandler handler = MicroBenchmarkHandlers.getInstance(out, benchmark, clazz, method, executionParams, options);
             if (warmup) {
                 executionParams = executionParams.warmupToIteration();
             }
-            outputHandler.startBenchmark(handler.getBenchmark(), executionParams, options.isVerbose());
+            out.startBenchmark(handler.getBenchmark(), executionParams, options.isVerbose());
             int iteration = 0;
             final Collection<ThreadIterationParams> threadIterationSequence = executionParams.getThreadIterationSequence();
             for (ThreadIterationParams tip : threadIterationSequence) {
@@ -452,13 +452,13 @@
             // only print end-of-run output if we have actual results
             if (!allResults.isEmpty()) {
                 RunResult result = aggregateIterationData(allResults);
-                outputHandler.endBenchmark(handler.getBenchmark(), result);
+                out.endBenchmark(handler.getBenchmark(), result);
             }
 
             handler.shutdown();
 
         } catch (Throwable ex) {
-            outputHandler.exception(ex);
+            out.exception(ex);
             if (options.shouldFailOnError()) {
                 throw new IllegalStateException(ex.getMessage(), ex);
             }