< prev index next >

test/gc/g1/TestPLABOutput.java

Print this page




  37 
  38 import java.util.regex.Matcher;
  39 import java.util.regex.Pattern;
  40 
  41 import jdk.test.lib.OutputAnalyzer;
  42 import jdk.test.lib.Platform;
  43 import jdk.test.lib.ProcessTools;
  44 
  45 import static jdk.test.lib.Asserts.*;
  46 
  47 public class TestPLABOutput {
  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             "-XX:+PrintGC",
  58             "-XX:+PrintPLAB",
  59             GCTest.class.getName()
  60             };
  61 
  62         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(arguments);
  63         OutputAnalyzer output = new OutputAnalyzer(pb.start());
  64 
  65         output.shouldHaveExitValue(0);
  66 
  67         System.out.println(output.getStdout());
  68 
  69         String pattern = "#0:.*allocated = (\\d+).*";
  70         Pattern r = Pattern.compile(pattern);
  71         Matcher m = r.matcher(output.getStdout());
  72 
  73         if (!m.find()) {
  74             throw new RuntimeException("Could not find any PLAB statistics output");
  75         }
  76         int allocated = Integer.parseInt(m.group(1));
  77         assertGT(allocated, 0, "Did not allocate any memory during test");
  78     }
  79 
  80     public static void main(String[] args) throws Exception {
  81         runTest();
  82     }
  83 
  84     static class GCTest {
  85         private static final WhiteBox WB = WhiteBox.getWhiteBox();
  86 
  87         public static Object holder;
  88 
  89         public static void main(String [] args) {


  37 
  38 import java.util.regex.Matcher;
  39 import java.util.regex.Pattern;
  40 
  41 import jdk.test.lib.OutputAnalyzer;
  42 import jdk.test.lib.Platform;
  43 import jdk.test.lib.ProcessTools;
  44 
  45 import static jdk.test.lib.Asserts.*;
  46 
  47 public class TestPLABOutput {
  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 >