< 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  */


  31 
  32 import sun.management.ManagementFactoryHelper;
  33 
  34 import static jdk.test.lib.Asserts.*;
  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  */


  31 
  32 import sun.management.ManagementFactoryHelper;
  33 
  34 import static jdk.test.lib.Asserts.*;
  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  * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UsePerfData -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC TestMetaspacePerfCounters
  52  *
  53  * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UsePerfData -XX:+UseSerialGC TestMetaspacePerfCounters
  54  * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UsePerfData -XX:+UseParallelGC -XX:+UseParallelOldGC TestMetaspacePerfCounters
  55  * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UsePerfData -XX:+UseG1GC TestMetaspacePerfCounters
  56  * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UsePerfData -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC TestMetaspacePerfCounters
  57  */
  58 public class TestMetaspacePerfCounters {
  59     public static Class fooClass = null;
  60     private static final String[] counterNames = {"minCapacity", "maxCapacity", "capacity", "used"};
  61     private static final List<GarbageCollectorMXBean> gcBeans = ManagementFactoryHelper.getGarbageCollectorMXBeans();
  62 
  63     public static void main(String[] args) throws Exception {
  64         String metaspace = "sun.gc.metaspace";
  65         String ccs = "sun.gc.compressedclassspace";
  66 
  67         checkPerfCounters(metaspace);
  68 
  69         if (isUsingCompressedClassPointers()) {
  70             checkPerfCounters(ccs);
  71             checkUsedIncreasesWhenLoadingClass(ccs);
  72         } else {
  73             checkEmptyPerfCounters(ccs);
  74             checkUsedIncreasesWhenLoadingClass(metaspace);
  75         }
  76     }


< prev index next >