changeset 836:8ffbc0429d53

profilers: delay logic cleanup.
author shade
date Thu, 26 Jun 2014 16:38:24 +0400
parents 014838b0d314
children 3afac862a651
files jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java
diffstat 2 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java	Thu Jun 26 15:40:05 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java	Thu Jun 26 16:38:24 2014 +0400
@@ -222,10 +222,12 @@
             delayNs = TimeUnit.MILLISECONDS.toNanos(DELAY_MSEC);
         }
 
-        Map<String, Multiset<Long>> events = readEvents(delayNs);
+        double skipSec = 1.0 * delayNs / TimeUnit.SECONDS.toNanos(1);
+
+        Map<String, Multiset<Long>> events = readEvents(skipSec);
 
         if (!events.isEmpty()) {
-            pw.println("Perf output processed:");
+            pw.printf("Perf output processed (skipped %.3f seconds):%n", skipSec);
             int cnt = 1;
             for (String event : EVENTS) {
                 pw.printf(" Column %d: %s (%d events)%n", cnt, event, events.get(event).size());
@@ -234,7 +236,8 @@
             pw.println();
         } else {
             pw.println();
-            pw.println("No perf data, make sure \"perf stat echo\" is indeed working.");
+            pw.println("No perf data, make sure \"perf stat echo\" is indeed working;\n " +
+                    "or the collection delay is not running past the benchmark time.");
             pw.println();
         }
 
@@ -507,7 +510,7 @@
         }
     }
 
-    Map<String, Multiset<Long>> readEvents(long skipNs) {
+    Map<String, Multiset<Long>> readEvents(double skipSec) {
         try {
             FileInputStream fis = new FileInputStream(perfParsedData);
             BufferedReader reader = new BufferedReader(new InputStreamReader(fis));
@@ -517,7 +520,6 @@
                 events.put(evName, new TreeMultiset<Long>());
             }
 
-            double skipSec = 1.0 * skipNs / TimeUnit.SECONDS.toNanos(1);
             Double startTime = null;
 
             String line;
--- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java	Thu Jun 26 15:40:05 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java	Thu Jun 26 16:38:24 2014 +0400
@@ -68,11 +68,9 @@
     public Collection<String> addJVMInvokeOptions(BenchmarkParams params) {
         long delay;
         if (DELAY_MSEC == -1) { // not set
-            delay = TimeUnit.NANOSECONDS.toMillis(
-                    params.getWarmup().getCount() *
-                            params.getWarmup().getTime().convertTo(TimeUnit.NANOSECONDS)
-                            + TimeUnit.SECONDS.toMillis(1) // loosely account for the JVM lag
-            );
+            delay = TimeUnit.NANOSECONDS.toMillis(params.getWarmup().getCount() *
+                            params.getWarmup().getTime().convertTo(TimeUnit.NANOSECONDS))
+                    + TimeUnit.SECONDS.toMillis(1); // loosely account for the JVM lag
         } else {
             delay = DELAY_MSEC;
         }