< prev index next >

test/gc/g1/TestPLABOutput.java

Print this page
rev 10336 : [mq]: 8141141-young-and-old-gen-stats-are-similar-in-output
   1 /*
   2  * Copyright (c) 2015, 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  */


  48 
  49     public static void runTest() throws Exception {
  50         final String[] arguments = {
  51             "-Xbootclasspath/a:.",
  52             "-XX:+UnlockExperimentalVMOptions",
  53             "-XX:+UnlockDiagnosticVMOptions",
  54             "-XX:+WhiteBoxAPI",
  55             "-XX:+UseG1GC",
  56             "-Xmx10M",
  57             "-Xlog:gc+plab=debug",
  58             GCTest.class.getName()
  59             };
  60 
  61         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(arguments);
  62         OutputAnalyzer output = new OutputAnalyzer(pb.start());
  63 
  64         output.shouldHaveExitValue(0);
  65 
  66         System.out.println(output.getStdout());
  67 
  68         String pattern = ".*GC\\(0\\) .*allocated = (\\d+).*";
  69         Pattern r = Pattern.compile(pattern);
  70         Matcher m = r.matcher(output.getStdout());
  71 
  72         if (!m.find()) {
  73             throw new RuntimeException("Could not find any PLAB statistics output");
  74         }
  75         int allocated = Integer.parseInt(m.group(1));
  76         assertGT(allocated, 0, "Did not allocate any memory during test");
  77     }
  78 
  79     public static void main(String[] args) throws Exception {
  80         runTest();
  81     }
  82 
  83     static class GCTest {
  84         private static final WhiteBox WB = WhiteBox.getWhiteBox();
  85 
  86         public static Object holder;
  87 
  88         public static void main(String [] args) {
   1 /*
   2  * Copyright (c) 2015, 2016, 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  */


  48 
  49     public static void runTest() throws Exception {
  50         final String[] arguments = {
  51             "-Xbootclasspath/a:.",
  52             "-XX:+UnlockExperimentalVMOptions",
  53             "-XX:+UnlockDiagnosticVMOptions",
  54             "-XX:+WhiteBoxAPI",
  55             "-XX:+UseG1GC",
  56             "-Xmx10M",
  57             "-Xlog:gc+plab=debug",
  58             GCTest.class.getName()
  59             };
  60 
  61         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(arguments);
  62         OutputAnalyzer output = new OutputAnalyzer(pb.start());
  63 
  64         output.shouldHaveExitValue(0);
  65 
  66         System.out.println(output.getStdout());
  67 
  68         String pattern = ".*GC\\(0\\) .*allocated: (\\d+).*";
  69         Pattern r = Pattern.compile(pattern);
  70         Matcher m = r.matcher(output.getStdout());
  71 
  72         if (!m.find()) {
  73             throw new RuntimeException("Could not find any PLAB statistics output");
  74         }
  75         int allocated = Integer.parseInt(m.group(1));
  76         assertGT(allocated, 0, "Did not allocate any memory during test");
  77     }
  78 
  79     public static void main(String[] args) throws Exception {
  80         runTest();
  81     }
  82 
  83     static class GCTest {
  84         private static final WhiteBox WB = WhiteBox.getWhiteBox();
  85 
  86         public static Object holder;
  87 
  88         public static void main(String [] args) {
< prev index next >