changeset 1030:2fd66b6d8f47

7901094: Warn users jvm*Args are useless when zero forks are used
author shade
date Wed, 12 Nov 2014 22:08:15 +0300
parents b79d21dc1789
children 17334d19ba94
files jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java
diffstat 1 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java	Wed Nov 12 17:39:25 2014 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java	Wed Nov 12 22:08:15 2014 +0300
@@ -77,8 +77,21 @@
             ActionMode mode = action.getMode();
 
             if (!forked) {
+                String opts = Utils.join(params.getJvmArgs(), " ").trim();
+                String realOpts = Utils.join(ManagementFactory.getRuntimeMXBean().getInputArguments(), " ").trim();
+                if (opts.isEmpty()) {
+                    opts = "<none>";
+                }
+                if (realOpts.isEmpty()) {
+                    realOpts = "<none>";
+                }
+
+                out.println("# VM invoker: " + params.getJvm());
+                out.println("# VM options: " + realOpts + (opts.equals(realOpts) ? "" : " *** WARNING: some JVM options are ignored in non-forked runs ***"));
+
+                out.startBenchmark(params);
+                out.println("");
                 etaBeforeBenchmark();
-                out.startBenchmark(params);
                 out.println("# Fork: N/A, test runs in the existing VM");
             }