< prev index next >

test/gc/metaspace/TestMetaspacePerfCounters.java

Print this page
rev 10588 : 8151460: Metaspace counters can have inconsistent values
Reviewed-by:
rev 10589 : [mq]: meta-rev


  67     private static void checkPerfCounters(String ns) throws Exception {
  68         long minCapacity = getMinCapacity(ns);
  69         long maxCapacity = getMaxCapacity(ns);
  70         long capacity = getCapacity(ns);
  71         long used = getUsed(ns);
  72 
  73         assertGTE(minCapacity, 0L);
  74         assertGTE(used, minCapacity);
  75         assertGTE(capacity, used);
  76         assertGTE(maxCapacity, capacity);
  77     }
  78 
  79     private static void checkEmptyPerfCounters(String ns) throws Exception {
  80         for (PerfCounter counter : countersInNamespace(ns)) {
  81             String msg = "Expected " + counter.getName() + " to equal 0";
  82             assertEQ(counter.longValue(), 0L, msg);
  83         }
  84     }
  85 
  86     private static void checkUsedIncreasesWhenLoadingClass(String ns) throws Exception {
  87         // Need to ensure that used is up to date and the all unloadable
  88         // classes are unloaded before doing this check.
  89         System.gc();
  90         long before = getUsed(ns);
  91         fooClass = compileAndLoad("Foo", "public class Foo { }");
  92         System.gc();
  93         long after = getUsed(ns);
  94 
  95         assertGT(after, before);
  96     }
  97 
  98     private static List<PerfCounter> countersInNamespace(String ns) throws Exception {
  99         List<PerfCounter> counters = new ArrayList<>();
 100         for (String name : counterNames) {
 101             counters.add(PerfCounters.findByName(ns + "." + name));
 102         }
 103         return counters;
 104     }
 105 
 106     private static Class<?> compileAndLoad(String name, String source) throws Exception {
 107         byte[] byteCode = InMemoryJavaCompiler.compile(name, source);




  67     private static void checkPerfCounters(String ns) throws Exception {
  68         long minCapacity = getMinCapacity(ns);
  69         long maxCapacity = getMaxCapacity(ns);
  70         long capacity = getCapacity(ns);
  71         long used = getUsed(ns);
  72 
  73         assertGTE(minCapacity, 0L);
  74         assertGTE(used, minCapacity);
  75         assertGTE(capacity, used);
  76         assertGTE(maxCapacity, capacity);
  77     }
  78 
  79     private static void checkEmptyPerfCounters(String ns) throws Exception {
  80         for (PerfCounter counter : countersInNamespace(ns)) {
  81             String msg = "Expected " + counter.getName() + " to equal 0";
  82             assertEQ(counter.longValue(), 0L, msg);
  83         }
  84     }
  85 
  86     private static void checkUsedIncreasesWhenLoadingClass(String ns) throws Exception {
  87         // Need to ensure that used is up to date and that all unreachable
  88         // classes are unloaded before doing this check.
  89         System.gc();
  90         long before = getUsed(ns);
  91         fooClass = compileAndLoad("Foo", "public class Foo { }");
  92         System.gc();
  93         long after = getUsed(ns);
  94 
  95         assertGT(after, before);
  96     }
  97 
  98     private static List<PerfCounter> countersInNamespace(String ns) throws Exception {
  99         List<PerfCounter> counters = new ArrayList<>();
 100         for (String name : counterNames) {
 101             counters.add(PerfCounters.findByName(ns + "." + name));
 102         }
 103         return counters;
 104     }
 105 
 106     private static Class<?> compileAndLoad(String name, String source) throws Exception {
 107         byte[] byteCode = InMemoryJavaCompiler.compile(name, source);


< prev index next >