changeset 1284:d36420b37599

Validation: more formatting touchups, version printing, etc.
author shade
date Fri, 11 Sep 2015 17:26:40 +0300
parents d12ded099b2e
children b995ada2e6b4
files jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/Main.java jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/ThermalRundownTest.java jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java jmh-core/src/main/java/org/openjdk/jmh/util/Version.java
diffstat 6 files changed, 46 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/Main.java	Fri Sep 11 16:08:01 2015 +0300
+++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/Main.java	Fri Sep 11 17:26:40 2015 +0300
@@ -28,6 +28,8 @@
 import org.openjdk.jmh.runner.CompilerHints;
 import org.openjdk.jmh.runner.RunnerException;
 import org.openjdk.jmh.runner.options.*;
+import org.openjdk.jmh.util.Utils;
+import org.openjdk.jmh.util.Version;
 import org.openjdk.jmh.validation.tests.*;
 
 import java.io.IOException;
@@ -41,24 +43,32 @@
     public static void main(String[] args) throws RunnerException, CommandLineOptionException, IOException {
         PrintWriter pw = new PrintWriter(System.out, true);
 
-        pw.println("JMH Core Benchmark Tests");
+        pw.println("JMH Core Benchmarks, Validation Tests");
         pw.println("----------------------------------------------------------------------------------------------------------");
         pw.println();
 
-        org.openjdk.jmh.util.Utils.reflow(pw,
+        pw.println("# " + Version.getVersion());
+        pw.println("# " + Utils.getCurrentJvmVersion());
+        pw.println("# " + Utils.getCurrentOSVersion());
+        pw.println();
+
+        Utils.reflow(pw,
                 "These tests assess the current benchmarking environment health, including hardware, OS, JVM, and JMH " +
                         "itself. While the failure on these tests does not immediately means the problem with environment, " +
                         "it is instructive to understand and follow up on oddities in these tests.",
                 80, 2);
         pw.println();
 
-        org.openjdk.jmh.util.Utils.reflow(pw,
+        Utils.reflow(pw,
                 "If you are sharing this report, please share it in full, including the JVM version, OS flavor and version, " +
                         "plus some data on used hardware.",
                 80, 2);
 
         pw.println();
 
+        pw.println("  Use -h to get help on available options.");
+        pw.println();
+
         OptionParser parser = new OptionParser();
         parser.formatHelpWith(new OptionFormatter());
 
--- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/ThermalRundownTest.java	Fri Sep 11 16:08:01 2015 +0300
+++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/ThermalRundownTest.java	Fri Sep 11 17:26:40 2015 +0300
@@ -51,7 +51,7 @@
         pw.println();
 
         org.openjdk.jmh.util.Utils.reflow(pw,
-                "This test tries to heat the machine up, forcing thermal throttling to kick in. If you see the diminishing " +
+                "This test tries to heat the machine up, trying to kick in the thermal throttling. If you see the diminishing " +
                         "performance over time, then your system throttles, and many benchmark experiments are unreliable. ",
                 80, 2);
         pw.println();
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java	Fri Sep 11 16:08:01 2015 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java	Fri Sep 11 17:26:40 2015 +0300
@@ -93,7 +93,7 @@
                 realOpts = "<none>";
             }
 
-            Version.printVersion(out);
+            out.println("# " + Version.getVersion());
             out.println("# VM version: " + Utils.getCurrentJvmVersion());
             out.println("# VM invoker: " + Utils.getCurrentJvm());
             out.println("# VM options: " + realOpts + (opts.equals(realOpts) ? "" : " *** WARNING: some JVM options are ignored in non-forked runs ***"));
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java	Fri Sep 11 16:08:01 2015 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java	Fri Sep 11 17:26:40 2015 +0300
@@ -604,7 +604,7 @@
                 opts = "<none>";
             }
 
-            Version.printVersion(out);
+            out.println("# " + Version.getVersion());
             out.print("# VM version: " + Utils.join(Utils.runWith(versionString), "\n"));
             out.println("# VM invoker: " + params.getJvm());
             out.println("# VM options: " + opts);
--- a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java	Fri Sep 11 16:08:01 2015 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java	Fri Sep 11 17:26:40 2015 +0300
@@ -329,13 +329,18 @@
     }
 
     public static String getCurrentJvmVersion() {
-        StringWriter sw = new StringWriter();
-        PrintWriter pw = new PrintWriter(sw);
-        pw.print("JDK ");
-        pw.print(System.getProperty("java.version"));
-        pw.print(", VM ");
-        pw.print(System.getProperty("java.vm.version"));
-        return sw.toString();
+        return "JDK "
+                + System.getProperty("java.version")
+                + ", VM "
+                + System.getProperty("java.vm.version");
+    }
+
+    public static String getCurrentOSVersion() {
+        return System.getProperty("os.name")
+                + ", "
+                + System.getProperty("os.arch")
+                + ", "
+                + System.getProperty("os.version");
     }
 
     /**
--- a/jmh-core/src/main/java/org/openjdk/jmh/util/Version.java	Fri Sep 11 16:08:01 2015 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/util/Version.java	Fri Sep 11 17:26:40 2015 +0300
@@ -24,10 +24,10 @@
  */
 package org.openjdk.jmh.util;
 
-import org.openjdk.jmh.runner.format.OutputFormat;
-
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
@@ -37,19 +37,28 @@
 
 public class Version {
 
-    public static void printVersion(OutputFormat pw) {
+    public static String getVersion() {
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+
+        printVersion(pw);
+        pw.close();
+        return sw.toString();
+    }
+
+    private static void printVersion(PrintWriter pw) {
         Properties p = new Properties();
         InputStream s = Version.class.getResourceAsStream("/jmh.properties");
 
         if (s == null) {
-            pw.println("# Cannot figure out JMH version, no jmh.properties");
+            pw.print("Cannot figure out JMH version, no jmh.properties");
             return;
         }
 
         try {
             p.load(s);
         } catch (IOException e) {
-            pw.println("# Cannot figure out JMH version");
+            pw.print("Cannot figure out JMH version");
             return;
         } finally {
             FileUtils.safelyClose(s);
@@ -57,15 +66,15 @@
 
         String version = (String) p.get("jmh.version");
         if (version == null) {
-            pw.println("# Cannot read jmh.version");
+            pw.print("Cannot read jmh.version");
             return;
         }
 
-        pw.print("# JMH " + version + " ");
+        pw.print("JMH " + version + " ");
 
         String time = (String) p.get("jmh.buildDate");
         if (time == null) {
-            pw.println("(cannot read jmh.buildDate)");
+            pw.print("(cannot read jmh.buildDate)");
             return;
         }
 
@@ -84,7 +93,7 @@
         } catch (ParseException e) {
             pw.print(time);
         }
-        pw.println(")");
+        pw.print(")");
     }
 
 }