changeset 343:f479fb156309

Clean up Defaults.
author shade
date Mon, 13 Jan 2014 20:19:43 +0400
parents f35ebe6117bf
children 85b9e57dc794
files jmh-core/src/main/java/org/openjdk/jmh/runner/BaseMicroBenchmarkHandler.java jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java jmh-core/src/main/java/org/openjdk/jmh/runner/LoopMicroBenchmarkHandler.java jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java jmh-core/src/main/java/org/openjdk/jmh/runner/parameters/BenchmarkParams.java jmh-core/src/main/java/org/openjdk/jmh/runner/parameters/Defaults.java
diffstat 6 files changed, 37 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseMicroBenchmarkHandler.java	Mon Jan 13 20:10:37 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseMicroBenchmarkHandler.java	Mon Jan 13 20:19:43 2014 +0400
@@ -83,7 +83,7 @@
         List<Profiler> list = new ArrayList<Profiler>();
         // register the profilers
         for (ProfilerType prof : options.getProfilers()) {
-            list.add(prof.createInstance(options.verbosity().orElse(Defaults.DEFAULT_VERBOSITY)));
+            list.add(prof.createInstance(options.verbosity().orElse(Defaults.VERBOSITY)));
         }
         return list;
     }
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java	Mon Jan 13 20:10:37 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java	Mon Jan 13 20:19:43 2014 +0400
@@ -105,7 +105,7 @@
             return runBenchmark(executionParams, handler);
         } catch (Throwable ex) {
             out.exception(ex);
-            if (options.shouldFailOnError().orElse(Defaults.SHOULD_FAIL_ON_ERROR)) {
+            if (options.shouldFailOnError().orElse(Defaults.FAIL_ON_ERROR)) {
                 throw new IllegalStateException(ex.getMessage(), ex);
             }
         } finally {
@@ -178,7 +178,7 @@
      * @return true if we did
      */
     public boolean runSystemGC() {
-        if (options.shouldDoGC().orElse(Defaults.SHOULD_DO_GC)) {
+        if (options.shouldDoGC().orElse(Defaults.DO_GC)) {
             List<GarbageCollectorMXBean> enabledBeans = new ArrayList<GarbageCollectorMXBean>();
 
             long beforeGcCount = 0;
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/LoopMicroBenchmarkHandler.java	Mon Jan 13 20:10:37 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/LoopMicroBenchmarkHandler.java	Mon Jan 13 20:19:43 2014 +0400
@@ -68,7 +68,7 @@
         super(format, microbenchmark, clazz, options, executionParams);
         this.method = method;
         this.shouldSynchIterations = (microbenchmark.getMode() != Mode.SingleShotTime) && executionParams.shouldSynchIterations();
-        this.shouldFailOnError = options.shouldFailOnError().orElse(Defaults.SHOULD_FAIL_ON_ERROR);
+        this.shouldFailOnError = options.shouldFailOnError().orElse(Defaults.FAIL_ON_ERROR);
     }
 
     /**
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java	Mon Jan 13 20:10:37 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java	Mon Jan 13 20:19:43 2014 +0400
@@ -112,7 +112,7 @@
             out = System.out;
         }
 
-        return OutputFormatFactory.createFormatInstance(out, options.verbosity().orElse(Defaults.DEFAULT_VERBOSITY));
+        return OutputFormatFactory.createFormatInstance(out, options.verbosity().orElse(Defaults.VERBOSITY));
     }
 
     public void list() {
@@ -153,7 +153,7 @@
         if (benchmarks.isEmpty()) {
             out.println("No matching benchmarks. Miss-spelled regexp?");
 
-            if (options.verbosity().orElse(Defaults.DEFAULT_VERBOSITY) != VerboseMode.EXTRA) {
+            if (options.verbosity().orElse(Defaults.VERBOSITY) != VerboseMode.EXTRA) {
                 out.println("Use " + VerboseMode.EXTRA + " verbose mode to debug the pattern matching.");
             } else {
                 list();
@@ -215,7 +215,7 @@
         if (warmupMicrosRegexp != null && !warmupMicrosRegexp.isEmpty()) {
             warmupBenches.addAll(list.find(out, warmupMicrosRegexp, Collections.<String>emptyList()));
         }
-        if (options.getWarmupMode().orElse(Defaults.DEFAULT_WARMUP_MODE).isBulk()) {
+        if (options.getWarmupMode().orElse(Defaults.WARMUP_MODE).isBulk()) {
             warmupBenches.addAll(benchmarks);
         }
 
@@ -226,7 +226,7 @@
         for (BenchmarkRecord br : benchmarks) {
             BenchmarkParams params = new BenchmarkParams(options, br, ActionMode.UNDEF);
             if (params.getForks() <= 0) {
-                if (options.getWarmupMode().orElse(Defaults.DEFAULT_WARMUP_MODE).isIndi()) {
+                if (options.getWarmupMode().orElse(Defaults.WARMUP_MODE).isIndi()) {
                     r.addWarmupMeasurement(br);
                 } else {
                     r.addMeasurement(br);
@@ -246,7 +246,7 @@
         if (warmupMicrosRegexp != null && !warmupMicrosRegexp.isEmpty()) {
             warmupBenches.addAll(list.find(out, warmupMicrosRegexp, Collections.<String>emptyList()));
         }
-        if (options.getWarmupMode().orElse(Defaults.DEFAULT_WARMUP_MODE).isBulk()) {
+        if (options.getWarmupMode().orElse(Defaults.WARMUP_MODE).isBulk()) {
             warmupBenches.addAll(benchmarks);
         }
 
@@ -260,7 +260,7 @@
             if (params.getForks() > 0) {
                 ActionPlan r = new ActionPlan();
                 r.mixIn(base);
-                if (options.getWarmupMode().orElse(Defaults.DEFAULT_WARMUP_MODE).isIndi()) {
+                if (options.getWarmupMode().orElse(Defaults.WARMUP_MODE).isIndi()) {
                     r.addWarmupMeasurement(br);
                 } else {
                     r.addMeasurement(br);
@@ -380,7 +380,7 @@
 
             if (ecode != 0) {
                 out.println("WARNING: Forked process returned code: " + ecode);
-                if (options.shouldFailOnError().orElse(Defaults.SHOULD_FAIL_ON_ERROR)) {
+                if (options.shouldFailOnError().orElse(Defaults.FAIL_ON_ERROR)) {
                     throw new IllegalStateException("WARNING: Forked process returned code: " + ecode);
                 }
             }
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/parameters/BenchmarkParams.java	Mon Jan 13 20:10:37 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/parameters/BenchmarkParams.java	Mon Jan 13 20:19:43 2014 +0400
@@ -72,7 +72,7 @@
         this.threads = Utils.roundUp(threads, Utils.sum(threadGroups));
 
         this.synchIterations = options.shouldSyncIterations().orElse(
-                Defaults.SHOULD_SYNCH_ITERATIONS);
+                Defaults.SYNC_ITERATIONS);
 
         this.measurement = mode.doMeasurement() ?
                 getMeasurement(options, benchmark) :
@@ -84,11 +84,11 @@
 
         this.forks = options.getForkCount().orElse(
                 benchmark.getForks().orElse(
-                        Defaults.DEFAULT_FORK_TIMES));
+                        Defaults.FORKS));
 
         this.warmupForks = options.getWarmupForkCount().orElse(
                 benchmark.getWarmupForks().orElse(
-                        Defaults.DEFAULT_WARMUP_FORK_TIMES));
+                        Defaults.WARMUP_FORKS));
     }
 
     private IterationParams getWarmup(Options options, BenchmarkRecord benchmark) {
@@ -96,7 +96,7 @@
                 this,
                 options.getWarmupIterations().orElse(
                         benchmark.getWarmupIterations().orElse(
-                            (benchmark.getMode() == Mode.SingleShotTime) ? Defaults.SINGLE_SHOT_WARMUP_COUNT : Defaults.WARMUP_ITERATION_COUNT
+                            (benchmark.getMode() == Mode.SingleShotTime) ? Defaults.SINGLESHOT_WARMUP_ITERATIONS : Defaults.WARMUP_ITERATIONS
                 )),
                 options.getWarmupTime().orElse(
                         benchmark.getWarmupTime().orElse(
@@ -110,7 +110,7 @@
                 this,
                 options.getMeasurementIterations().orElse(
                         benchmark.getMeasurementIterations().orElse(
-                                (benchmark.getMode() == Mode.SingleShotTime) ? Defaults.SINGLE_SHOT_ITERATION_COUNT : Defaults.MEASUREMENT_ITERATION_COUNT
+                                (benchmark.getMode() == Mode.SingleShotTime) ? Defaults.SINGLESHOT_MEASUREMENT_ITERATIONS : Defaults.MEASUREMENT_ITERATIONS
                         )),
                 options.getMeasurementTime().orElse(
                         benchmark.getMeasurementTime().orElse(
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/parameters/Defaults.java	Mon Jan 13 20:10:37 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/parameters/Defaults.java	Mon Jan 13 20:19:43 2014 +0400
@@ -34,35 +34,39 @@
 import java.util.concurrent.TimeUnit;
 
 /**
- * @author sergey.kuksenko@oracle.com
+ * Holds the JMH global defaults.
+ *
+ * @author Sergey Kuksenko
+ * @author Aleksey Shipilev
  */
 public class Defaults {
 
     public static final List<String> TRUE_VALUES  = Collections.unmodifiableList(Arrays.asList("true", "on", "yes"));
     public static final List<String> FALSE_VALUES = Collections.unmodifiableList(Arrays.asList("false", "off", "no"));
 
-    public static final int MEASUREMENT_TIME_SECS = 1;
-    public static final int MEASUREMENT_ITERATION_COUNT = 20;
-    public static final int SINGLE_SHOT_ITERATION_COUNT = 1;
+    public static final int MEASUREMENT_ITERATIONS = 20;
+    public static final int SINGLESHOT_MEASUREMENT_ITERATIONS = 1;
 
-    public static final int WARMUP_TIME_SECS = 1;
-    public static final int WARMUP_ITERATION_COUNT = 20;
-    public static final int SINGLE_SHOT_WARMUP_COUNT = 0;
+    public static final int WARMUP_ITERATIONS = 20;
+    public static final int SINGLESHOT_WARMUP_ITERATIONS = 0;
 
-    public static final TimeValue WARMUP_TIME = new TimeValue(WARMUP_TIME_SECS, TimeUnit.SECONDS);
-    public static final TimeValue ITERATION_TIME = new TimeValue(MEASUREMENT_TIME_SECS, TimeUnit.SECONDS);
+    public static final TimeValue WARMUP_TIME = new TimeValue(1, TimeUnit.SECONDS);
+    public static final TimeValue ITERATION_TIME = new TimeValue(1, TimeUnit.SECONDS);
 
     public static final int THREADS = 1;
 
-    public static final int DEFAULT_WARMUP_FORK_TIMES = 0;
-    public static final int DEFAULT_FORK_TIMES = 10;
+    public static final int FORKS = 10;
+    public static final int WARMUP_FORKS = 0;
 
-    public static final boolean SHOULD_SYNCH_ITERATIONS = true;
+    public static final boolean FAIL_ON_ERROR = false;
+    public static final boolean SYNC_ITERATIONS = true;
+    public static final boolean DO_GC = false;
 
+    public static final ResultFormatType RESULT_FORMAT = ResultFormatType.NONE;
     public static final String RESULT_FILE = "jmh.out";
-    public static final VerboseMode DEFAULT_VERBOSITY = VerboseMode.NORMAL;
-    public static final Boolean SHOULD_FAIL_ON_ERROR = false;
-    public static final WarmupMode DEFAULT_WARMUP_MODE = WarmupMode.INDI;
-    public static final ResultFormatType RESULT_FORMAT = ResultFormatType.NONE;
-    public static final Boolean SHOULD_DO_GC = false;
+
+    public static final WarmupMode WARMUP_MODE = WarmupMode.INDI;
+
+    public static final VerboseMode VERBOSITY = VerboseMode.NORMAL;
+
 }