changeset 148:ca8d6876f031

Move out Options.shouldList().
author shade
date Tue, 27 Aug 2013 14:35:35 +0400
parents f8d3b5ff18ee
children 9b447ea48fa3
files jmh-core/src/main/java/org/openjdk/jmh/Main.java jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java jmh-core/src/main/java/org/openjdk/jmh/runner/options/DefaultBuilder.java jmh-core/src/main/java/org/openjdk/jmh/runner/options/ForkedOptions.java jmh-core/src/main/java/org/openjdk/jmh/runner/options/HarnessOptions.java jmh-core/src/main/java/org/openjdk/jmh/runner/options/Options.java jmh-core/src/main/java/org/openjdk/jmh/runner/options/OptionsBuilder.java
diffstat 7 files changed, 23 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/Main.java	Tue Aug 27 14:05:34 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/Main.java	Tue Aug 27 14:35:35 2013 +0400
@@ -95,6 +95,12 @@
             }
 
             Runner runner = new Runner(cmdOptions);
+
+            if (cmdOptions.shouldList()) {
+                runner.list();
+                return;
+            }
+
             runner.run();
         } catch (CmdLineException ex) {
             cmdOptions.printUsage(ex.getMessage());
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java	Tue Aug 27 14:05:34 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java	Tue Aug 27 14:35:35 2013 +0400
@@ -95,6 +95,15 @@
         return OutputFormatFactory.createFormatInstance(out, options.getOutputFormat(), options.isVerbose());
     }
 
+    public void list() {
+        Set<BenchmarkRecord> benchmarks = list.find(out, options.getRegexps(), options.getExcludes());
+
+        out.println("Benchmarks: ");
+        for (BenchmarkRecord benchmark : benchmarks) {
+            out.println(benchmark.getUsername());
+        }
+    }
+
     /** Main entry point */
     public void run() throws RunnerException {
         Set<BenchmarkRecord> benchmarks = list.find(out, options.getRegexps(), options.getExcludes());
@@ -106,13 +115,9 @@
             return;
         }
 
-        if (options.shouldList() || options.isVerbose()) {
-            out.println("Benchmarks: ");
-
-            // list microbenchmarks if -l and/or -v
-            for (BenchmarkRecord benchmark : benchmarks) {
-                out.println(benchmark.getUsername());
-            }
+        // list microbenchmarks if -v
+        if (options.isVerbose()) {
+            list();
         }
 
         // override the benchmark types;
@@ -146,14 +151,11 @@
         benchmarks.clear();
         benchmarks.addAll(newBenchmarks);
 
-        // exit if list only, else run benchmarks
-        if (!options.shouldList()) {
-            if ((!options.getWarmupMicros().isEmpty()) ||
-                    (options.getWarmupMode() == WarmupMode.BEFOREANY)) {
-                runBulkWarmupBenchmarks(benchmarks);
-            } else {
-                runBenchmarks(benchmarks);
-            }
+        if ((!options.getWarmupMicros().isEmpty()) ||
+                (options.getWarmupMode() == WarmupMode.BEFOREANY)) {
+            runBulkWarmupBenchmarks(benchmarks);
+        } else {
+            runBenchmarks(benchmarks);
         }
 
         out.flush();
@@ -448,5 +450,4 @@
         return command.toArray(new String[command.size()]);
     }
 
-
 }
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/options/DefaultBuilder.java	Tue Aug 27 14:05:34 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/options/DefaultBuilder.java	Tue Aug 27 14:35:35 2013 +0400
@@ -134,21 +134,6 @@
 
     // ---------------------------------------------------------------------------
 
-    private boolean shouldList;
-
-    @Override
-    public OptionsBuilder shouldList(boolean value) {
-        shouldList = value;
-        return this;
-    }
-
-    @Override
-    public boolean shouldList() {
-        return shouldList;
-    }
-
-    // ---------------------------------------------------------------------------
-
     private EnumSet<ProfilerType> profilers = EnumSet.noneOf(ProfilerType.class);
 
     @Override
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/options/ForkedOptions.java	Tue Aug 27 14:05:34 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/options/ForkedOptions.java	Tue Aug 27 14:35:35 2013 +0400
@@ -109,11 +109,6 @@
     }
 
     @Override
-    public boolean shouldList() {
-        throw new UnsupportedOperationException("Asking for harness option");
-    }
-
-    @Override
     public List<String> getWarmupMicros() {
         throw new UnsupportedOperationException("Asking for harness option");
     }
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/options/HarnessOptions.java	Tue Aug 27 14:05:34 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/options/HarnessOptions.java	Tue Aug 27 14:35:35 2013 +0400
@@ -183,7 +183,6 @@
      *
      * @return the value
      */
-    @Override
     public boolean shouldList() {
         return list;
     }
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/options/Options.java	Tue Aug 27 14:05:34 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/options/Options.java	Tue Aug 27 14:35:35 2013 +0400
@@ -67,13 +67,6 @@
     boolean shouldDoGC();
 
     /**
-     * Should list benchmarks?
-     * TODO: Deprecate
-     * @return should list?
-     */
-    boolean shouldList();
-
-    /**
      * Profilers to use for the run.
      * @return profilers to use; empty set if no profilers are required
      */
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/options/OptionsBuilder.java	Tue Aug 27 14:05:34 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/options/OptionsBuilder.java	Tue Aug 27 14:35:35 2013 +0400
@@ -44,8 +44,6 @@
 
     OptionsBuilder shouldDoGC(boolean value);
 
-    OptionsBuilder shouldList(boolean value);
-
     OptionsBuilder addProfiler(ProfilerType prof);
 
     OptionsBuilder shouldBeVerbose(boolean value);