< prev index next >

test/hotspot/jtreg/gc/metaspace/TestMetaspacePerfCounters.java

Print this page


   1 /*
   2  * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


  35 import gc.testlibrary.PerfCounter;
  36 import gc.testlibrary.PerfCounters;
  37 
  38 /* @test TestMetaspacePerfCounters
  39  * @bug 8014659
  40  * @requires vm.gc=="null"
  41  * @library /test/lib /
  42  * @summary Tests that performance counters for metaspace and compressed class
  43  *          space exists and works.
  44  * @modules java.base/jdk.internal.misc
  45  *          java.compiler
  46  *          java.management/sun.management
  47  *          jdk.internal.jvmstat/sun.jvmstat.monitor
  48  * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UsePerfData -XX:+UseSerialGC TestMetaspacePerfCounters
  49  * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UsePerfData -XX:+UseParallelGC -XX:+UseParallelOldGC TestMetaspacePerfCounters
  50  * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UsePerfData -XX:+UseG1GC TestMetaspacePerfCounters
  51  *
  52  * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UsePerfData -XX:+UseSerialGC TestMetaspacePerfCounters
  53  * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UsePerfData -XX:+UseParallelGC -XX:+UseParallelOldGC TestMetaspacePerfCounters
  54  * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UsePerfData -XX:+UseG1GC TestMetaspacePerfCounters














  55  */
  56 public class TestMetaspacePerfCounters {
  57     public static Class fooClass = null;
  58     private static final String[] counterNames = {"minCapacity", "maxCapacity", "capacity", "used"};
  59     private static final List<GarbageCollectorMXBean> gcBeans = ManagementFactoryHelper.getGarbageCollectorMXBeans();
  60 
  61     public static void main(String[] args) throws Exception {
  62         String metaspace = "sun.gc.metaspace";
  63         String ccs = "sun.gc.compressedclassspace";
  64 
  65         checkPerfCounters(metaspace);
  66 
  67         if (isUsingCompressedClassPointers()) {
  68             checkPerfCounters(ccs);
  69             checkUsedIncreasesWhenLoadingClass(ccs);
  70         } else {
  71             checkEmptyPerfCounters(ccs);
  72             checkUsedIncreasesWhenLoadingClass(metaspace);
  73         }
  74     }


   1 /*
   2  * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


  35 import gc.testlibrary.PerfCounter;
  36 import gc.testlibrary.PerfCounters;
  37 
  38 /* @test TestMetaspacePerfCounters
  39  * @bug 8014659
  40  * @requires vm.gc=="null"
  41  * @library /test/lib /
  42  * @summary Tests that performance counters for metaspace and compressed class
  43  *          space exists and works.
  44  * @modules java.base/jdk.internal.misc
  45  *          java.compiler
  46  *          java.management/sun.management
  47  *          jdk.internal.jvmstat/sun.jvmstat.monitor
  48  * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UsePerfData -XX:+UseSerialGC TestMetaspacePerfCounters
  49  * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UsePerfData -XX:+UseParallelGC -XX:+UseParallelOldGC TestMetaspacePerfCounters
  50  * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UsePerfData -XX:+UseG1GC TestMetaspacePerfCounters
  51  *
  52  * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UsePerfData -XX:+UseSerialGC TestMetaspacePerfCounters
  53  * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UsePerfData -XX:+UseParallelGC -XX:+UseParallelOldGC TestMetaspacePerfCounters
  54  * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UsePerfData -XX:+UseG1GC TestMetaspacePerfCounters
  55  */
  56 
  57 /* @test TestMetaspacePerfCountersShenandoah
  58  * @bug 8014659
  59  * @requires vm.gc.Shenandoah
  60  * @library /test/lib /
  61  * @summary Tests that performance counters for metaspace and compressed class
  62  *          space exists and works.
  63  * @modules java.base/jdk.internal.misc
  64  *          java.compiler
  65  *          java.management/sun.management
  66  *          jdk.internal.jvmstat/sun.jvmstat.monitor
  67  * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UsePerfData -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC TestMetaspacePerfCounters
  68  * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UsePerfData -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC TestMetaspacePerfCounters
  69  */
  70 public class TestMetaspacePerfCounters {
  71     public static Class fooClass = null;
  72     private static final String[] counterNames = {"minCapacity", "maxCapacity", "capacity", "used"};
  73     private static final List<GarbageCollectorMXBean> gcBeans = ManagementFactoryHelper.getGarbageCollectorMXBeans();
  74 
  75     public static void main(String[] args) throws Exception {
  76         String metaspace = "sun.gc.metaspace";
  77         String ccs = "sun.gc.compressedclassspace";
  78 
  79         checkPerfCounters(metaspace);
  80 
  81         if (isUsingCompressedClassPointers()) {
  82             checkPerfCounters(ccs);
  83             checkUsedIncreasesWhenLoadingClass(ccs);
  84         } else {
  85             checkEmptyPerfCounters(ccs);
  86             checkUsedIncreasesWhenLoadingClass(metaspace);
  87         }
  88     }


< prev index next >