changeset 1191:1898f77c754c

Reinstate GCProfile "observed spaces" machinery after 7901374.
author shade
date Tue, 07 Apr 2015 13:13:18 +0300
parents 36437173192a
children 971a0c94beba
files jmh-core/src/main/java/org/openjdk/jmh/profile/GCProfiler.java
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/profile/GCProfiler.java	Tue Apr 07 13:01:26 2015 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/GCProfiler.java	Tue Apr 07 13:13:18 2015 +0300
@@ -45,8 +45,11 @@
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.TimeUnit;
 
 public class GCProfiler implements InternalProfiler {
@@ -55,9 +58,11 @@
     private long beforeGCTime;
     private final NotificationListener listener;
     private volatile Multiset<String> churn;
+    private Set<String> observedSpaces;
 
     public GCProfiler() {
         churn = new HashMultiset<String>();
+        observedSpaces = Collections.synchronizedSet(new HashSet<String>());
 
         NotificationListener listener = null;
         try {
@@ -84,6 +89,7 @@
                                 long c = before.getUsed() - after.getUsed();
                                 if (c > 0) {
                                     churn.add(name, c);
+                                    observedSpaces.add(name);
                                 }
                             }
                         }
@@ -161,7 +167,7 @@
                 "ms",
                 AggregationPolicy.SUM));
 
-        for (String space : churn.keys()) {
+        for (String space : observedSpaces) {
             double churnRate = 1.0 * churn.count(space) * TimeUnit.SECONDS.toNanos(1) / (afterTime - beforeTime);
 
             results.add(new ProfilerResult(