RFR: remove unnecessary trace output

Sergey Kuksenko sergey.kuksenko at oracle.com
Tue Jun 11 05:41:47 PDT 2013


Hi All,

I am suggesting to remove useless trace output methods (start/end 
iteration). Support of this makes overcomplicated OutputFormat logic.
----- patch starts here---------------------------

diff -r 81994ce1bd24 
jmh-core/src/main/java/org/openjdk/jmh/output/format/CsvFormat.java
--- 
a/jmh-core/src/main/java/org/openjdk/jmh/output/format/CsvFormat.java 
Tue Jun 11 12:30:05 2013 +0400
+++ 
b/jmh-core/src/main/java/org/openjdk/jmh/output/format/CsvFormat.java 
Tue Jun 11 16:22:33 2013 +0400
@@ -101,15 +101,6 @@
      }

      @Override
-    public void traceStartIteration() {
-        // don't print anything
-    }
-
-    @Override
-    public void traceEndIteration() {
-    }
-
-    @Override
      public void warmupIteration(BenchmarkRecord benchmark, int 
iteration, int threads, TimeValue warmupTime) {
          // don't print anything
      }
@@ -145,13 +136,4 @@
      public void threadSubStatistics(BenchmarkRecord name, int threads, 
RunResult result) {

      }
-
-    @Override
-    public void traceHarnessMethodInvoked(String methodName) {
-    }
-
-    @Override
-    public void traceHarnessMethodReturned(String methodName) {
-    }
-
  }
diff -r 81994ce1bd24 
jmh-core/src/main/java/org/openjdk/jmh/output/format/OutputFormat.java
--- 
a/jmh-core/src/main/java/org/openjdk/jmh/output/format/OutputFormat.java	Tue 
Jun 11 12:30:05 2013 +0400
+++ 
b/jmh-core/src/main/java/org/openjdk/jmh/output/format/OutputFormat.java	Tue 
Jun 11 16:22:33 2013 +0400
@@ -135,30 +135,6 @@

      /* ------------- SPECIAL TRACING METHODS -------------------- */

-    /**
-     * Format for tracing iteration start time.
-     */
-    public void traceStartIteration();
-
-    /**
-     * Format for tracing iteration end time.
-     */
-    public void traceEndIteration();
-
-    /**
-     * Format for harness method invocation diagnostic output.
-     *
-     * @param methodName method name
-     */
-    public void traceHarnessMethodInvoked(String methodName);
-
-    /**
-     * Format for harness method return diagnostic output.
-     *
-     * @param methodName method name
-     */
-    public void traceHarnessMethodReturned(String methodName);
-
      void exception(Throwable ex);

      /* ------------- RAW OUTPUT METHODS ------------------- */
diff -r 81994ce1bd24 
jmh-core/src/main/java/org/openjdk/jmh/output/format/PrettyPrintFormat.java
--- 
a/jmh-core/src/main/java/org/openjdk/jmh/output/format/PrettyPrintFormat.java 
Tue Jun 11 12:30:05 2013 +0400
+++ 
b/jmh-core/src/main/java/org/openjdk/jmh/output/format/PrettyPrintFormat.java 
Tue Jun 11 16:22:33 2013 +0400
@@ -202,38 +202,6 @@

      }

-    @Override
-    public void traceStartIteration() {
-        if (verbose) {
-            out.println("# Iteration   started at " + new Date() + " in 
" + Thread.currentThread());
-            out.flush();
-        }
-    }
-
-    @Override
-    public void traceEndIteration() {
-        if (verbose) {
-            out.println("# Iteration completed at " + new Date() + " in 
" + Thread.currentThread());
-            out.flush();
-        }
-    }
-
-    @Override
-    public void traceHarnessMethodInvoked(String methodName) {
-        if (verbose) {
-            out.println("# Invoking " + methodName + " in " + 
Thread.currentThread());
-            out.flush();
-        }
-    }
-
-    @Override
-    public void traceHarnessMethodReturned(String methodName) {
-        if (verbose) {
-            out.println("# Returned from " + methodName + " in " + 
Thread.currentThread());
-            out.flush();
-        }
-    }
-
      protected static String getThreadsString(int t) {
          if (t > 1) {
              return "threads";
diff -r 81994ce1bd24 
jmh-core/src/main/java/org/openjdk/jmh/output/format/SilentFormat.java
--- 
a/jmh-core/src/main/java/org/openjdk/jmh/output/format/SilentFormat.java	Tue 
Jun 11 12:30:05 2013 +0400
+++ 
b/jmh-core/src/main/java/org/openjdk/jmh/output/format/SilentFormat.java	Tue 
Jun 11 16:22:33 2013 +0400
@@ -79,14 +79,6 @@
      }

      @Override
-    public void traceStartIteration() {
-    }
-
-    @Override
-    public void traceEndIteration() {
-    }
-
-    @Override
      public void iterationResult(BenchmarkRecord name, int iteration, 
int thread, IterationResult result, Collection<ProfilerResult> profiles) {

      }
@@ -100,12 +92,5 @@

      }

-    @Override
-    public void traceHarnessMethodInvoked(String methodName) {
-    }
-
-    @Override
-    public void traceHarnessMethodReturned(String methodName) {
-    }

  }
diff -r 81994ce1bd24 
jmh-core/src/main/java/org/openjdk/jmh/runner/LoopMicroBenchmarkHandler.java
--- 
a/jmh-core/src/main/java/org/openjdk/jmh/runner/LoopMicroBenchmarkHandler.java 
Tue Jun 11 12:30:05 2013 +0400
+++ 
b/jmh-core/src/main/java/org/openjdk/jmh/runner/LoopMicroBenchmarkHandler.java 
Tue Jun 11 16:22:33 2013 +0400
@@ -64,7 +64,6 @@

      /* output options */
      private final boolean shouldFailOnError;
-    private final boolean shouldTraceBenchmarkStartStop;

      /**
       * Constructor
@@ -80,7 +79,6 @@
          this.method = method;
          this.shouldSynchIterations = 
executionParams.shouldSynchIterations();
          this.shouldFailOnError = options.shouldFailOnError();
-        this.shouldTraceBenchmarkStartStop = 
options.shouldTraceBenchmarkStartStop();
      }

      /**
@@ -229,10 +227,6 @@

          private Result invokeBenchmark(Object instance, Loop loop) 
throws Throwable {
              Result result;
-            if (shouldTraceBenchmarkStartStop) {
-                format.traceStartIteration();
-            }
-
              if (method != null) {
                  try {
                      result = (Result) method.invoke(instance, loop);
@@ -244,11 +238,6 @@
              } else {
                  throw new IllegalStateException("Unable to find method 
to run");
              }
-
-            if (shouldTraceBenchmarkStartStop) {
-                format.traceEndIteration();
-            }
-
              return result;
          }

diff -r 81994ce1bd24 
jmh-core/src/main/java/org/openjdk/jmh/runner/ShotMicroBenchmarkHandler.java
--- 
a/jmh-core/src/main/java/org/openjdk/jmh/runner/ShotMicroBenchmarkHandler.java 
Tue Jun 11 12:30:05 2013 +0400
+++ 
b/jmh-core/src/main/java/org/openjdk/jmh/runner/ShotMicroBenchmarkHandler.java 
Tue Jun 11 16:22:33 2013 +0400
@@ -56,7 +56,6 @@

      /* output options */
      private final boolean shouldFailOnError;
-    private final boolean shouldTraceBenchmarkStartStop;

      /**
       * Constructor
@@ -71,7 +70,6 @@
          super(format, microbenchmark, clazz, options, executionParams);
          this.method = method;
          this.shouldFailOnError = options.shouldFailOnError();
-        this.shouldTraceBenchmarkStartStop = 
options.shouldTraceBenchmarkStartStop();
      }

      /**
@@ -202,9 +200,6 @@
           */
          private Result invokeBenchmark(Object instance) throws Throwable {
              Result result;
-            if (shouldTraceBenchmarkStartStop) {
-                format.traceStartIteration();
-            }

              if (method != null) {
                  try {
@@ -218,10 +213,6 @@
                  throw new IllegalStateException("Unable to find method 
to run");
              }

-            if (shouldTraceBenchmarkStartStop) {
-                format.traceEndIteration();
-            }
-
              return result;
          }

diff -r 81994ce1bd24 
jmh-core/src/main/java/org/openjdk/jmh/runner/options/BaseOptions.java
--- 
a/jmh-core/src/main/java/org/openjdk/jmh/runner/options/BaseOptions.java	Tue 
Jun 11 12:30:05 2013 +0400
+++ 
b/jmh-core/src/main/java/org/openjdk/jmh/runner/options/BaseOptions.java	Tue 
Jun 11 16:22:33 2013 +0400
@@ -464,24 +464,6 @@
      }

      /**
-     * returns true if harness should trace benchmark start/stop
-     *
-     * @return the value
-     */
-    public boolean shouldTraceBenchmarkStartStop() {
-        return traceLevel > 0;
-    }
-
-    /**
-     * return true if harness should trace Setup/tearDown
-     *
-     * @return the value
-     */
-    public boolean shouldTraceSetupTeardown() {
-        return traceLevel > 1;
-    }
-
-    /**
       * Should fail the harness on test error?
       * @return the value
       */


More information about the jmh-dev mailing list