changeset 1387:1e15cc553559

7901860: safepoints profiler should filter the events correctly, and report the measurement interval
author shade
date Mon, 05 Dec 2016 20:40:04 +0100
parents eba61e9f1d2a
children 49b0a822bc1f
files jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java
diffstat 1 files changed, 9 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java	Mon Dec 05 12:49:50 2016 +0100
+++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java	Mon Dec 05 20:40:04 2016 +0100
@@ -73,8 +73,11 @@
 
     @Override
     public Collection<? extends Result> afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) {
-        long skip = ProfilerUtils.warmupDelayMs(br);
-        long measuredTime = ProfilerUtils.measuredTimeMs(br);
+        long measuredTimeMs = ProfilerUtils.measuredTimeMs(br);
+        long measuredTimeNs = TimeUnit.MILLISECONDS.toNanos(measuredTimeMs);
+
+        long measureFrom = TimeUnit.MILLISECONDS.toNanos(ProfilerUtils.warmupDelayMs(br));
+        long measureTo = measureFrom + measuredTimeNs;
 
         List<ParsedData> ds = new ArrayList<>();
 
@@ -101,7 +104,8 @@
         SampleBuffer ttspBuff = new SampleBuffer();
 
         for (ParsedData d : ds) {
-            if (d.ver == maxVer && d.timestamp > skip) {
+            if (d.ver == maxVer &&
+                    (d.timestamp > measureFrom) && (d.timestamp < measureTo)) {
                 pauseBuff.add(d.stopTime);
                 if (d.ttspTime != NO_LONG_VALUE) {
                     ttspBuff.add(d.ttspTime);
@@ -111,9 +115,8 @@
 
         Collection<Result> results = new ArrayList<>();
 
-        results.add(new ScalarResult(Defaults.PREFIX + "safepoints.app.stopped",
-                pauseBuff.getStatistics(100).getSum() / TimeUnit.MILLISECONDS.toNanos(measuredTime),
-                "%", AggregationPolicy.AVG));
+        results.add(new ScalarResult(Defaults.PREFIX + "safepoints.interval",
+                measuredTimeMs, "ms", AggregationPolicy.SUM));
 
         results.add(new SafepointProfilerResult("pause", pauseBuff));