changeset 138:f357993710a8

Remove ExecutionMode, make the dispatch cleaner.
author shade
date Fri, 23 Aug 2013 12:32:13 +0400
parents 0cea178f3eb4
children b3932d6c6377
files jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java jmh-core/src/main/java/org/openjdk/jmh/runner/options/HarnessOptions.java
diffstat 2 files changed, 11 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java	Fri Aug 23 12:18:50 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java	Fri Aug 23 12:32:13 2013 +0400
@@ -26,16 +26,12 @@
 
 import org.openjdk.jmh.annotations.Fork;
 import org.openjdk.jmh.annotations.Mode;
-import org.openjdk.jmh.logic.results.IterationData;
 import org.openjdk.jmh.output.OutputFormatFactory;
 import org.openjdk.jmh.output.format.OutputFormat;
 import org.openjdk.jmh.output.format.internal.BinaryOutputFormatReader;
 import org.openjdk.jmh.runner.options.HarnessOptions;
 import org.openjdk.jmh.runner.parameters.Defaults;
-import org.openjdk.jmh.runner.parameters.MicroBenchmarkParameters;
-import org.openjdk.jmh.runner.parameters.MicroBenchmarkParametersFactory;
 import org.openjdk.jmh.util.AnnotationUtils;
-import org.openjdk.jmh.util.ClassUtils;
 import org.openjdk.jmh.util.InputStreamDrainer;
 
 import java.io.BufferedOutputStream;
@@ -75,37 +71,6 @@
         this.options = options;
     }
 
-    public enum ExecutionMode {
-        /**
-         * classic mode:
-         *   - single JVM for all microbenchmarks (unless benchmark requires forked JVM itself),
-         *   - warmup performed before each microbenchmark
-         *   - -frw options will exec additional warmup on increasing amount of threads
-         */
-        CLASSIC,
-        /**
-         * - exec bulk warmup micrbenchmarks using --warmupmicrobenchmarks option or -warmupmode beforeAny
-         * - there is no any kind of warmup when iteration started
-         */
-        BULK_WARMUP,
-        /**
-         *   Fork JVM for each benchmark.
-         *   Child harness (forked) is running in CLASSIC mode.
-         */
-        FORK_ALL;
-
-        public static ExecutionMode getExecutionMode(HarnessOptions options) {
-            if (options.getForkCount() > 0) {
-                return FORK_ALL;
-            } else if ((options.getWarmupMicros() != null && !options.getWarmupMicros().isEmpty()) ||
-                       (options.getWarmupMode() == HarnessOptions.WarmupMode.BEFOREANY)) {
-                return BULK_WARMUP;
-            } else {
-                return CLASSIC;
-            }
-        }
-    }
-
     /** Setup helper method, creates OutputFormat according to argv options. */
     public static OutputFormat createOutputFormat(HarnessOptions options) {
         PrintStream out;
@@ -175,18 +140,12 @@
         benchmarks.addAll(newBenchmarks);
 
         // exit if list only, else run benchmarks
-        if (!options.shouldList() && !benchmarks.isEmpty()) {
-            switch (ExecutionMode.getExecutionMode(options)) {
-                case CLASSIC:
-                case FORK_ALL:
-                    runBenchmarks(benchmarks);
-                    break;
-                case BULK_WARMUP:
-                    runBulkWarmupBenchmarks(benchmarks, list);
-                    break;
-                default:
-                    throw new IllegalArgumentException("Internal error: unknown execution mode");
-
+        if (!options.shouldList()) {
+            if ((!options.getWarmupMicros().isEmpty()) ||
+                    (options.getWarmupMode() == HarnessOptions.WarmupMode.BEFOREANY)) {
+                runBulkWarmupBenchmarks(benchmarks, list);
+            } else {
+                runBenchmarks(benchmarks);
             }
         }
 
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/options/HarnessOptions.java	Fri Aug 23 12:18:50 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/options/HarnessOptions.java	Fri Aug 23 12:32:13 2013 +0400
@@ -283,7 +283,11 @@
      * @return the value
      */
     public List<String> getWarmupMicros() {
-        return warmupMicros;
+        if (warmupMicros == null) {
+            return Collections.emptyList();
+        } else {
+            return warmupMicros;
+        }
     }
 
     /**