< prev index next >

test/gc/g1/TestPrintRegionRememberedSetInfo.java

Print this page




  40 
  41 class RunAndWaitForMarking {
  42     public static void main(String[] args) {
  43         System.gc();
  44         try {
  45             Thread.sleep(200);
  46         } catch (InterruptedException e) {
  47         }
  48     }
  49 }
  50 
  51 public class TestPrintRegionRememberedSetInfo {
  52 
  53     public static String runTest(String arg) throws Exception {
  54         ArrayList<String> finalargs = new ArrayList<String>();
  55         String[] defaultArgs = new String[] {
  56             "-XX:+UseG1GC",
  57             "-Xmx10m",
  58             "-XX:+ExplicitGCInvokesConcurrent",
  59             "-XX:+UnlockDiagnosticVMOptions",
  60             "-XX:+G1PrintRegionLivenessInfo",
  61             "-XX:G1HeapRegionSize=1M",
  62             "-XX:InitiatingHeapOccupancyPercent=0",
  63         };
  64 
  65         finalargs.addAll(Arrays.asList(defaultArgs));
  66         finalargs.add(arg);
  67 
  68         finalargs.add(RunAndWaitForMarking.class.getName());
  69 
  70         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
  71             finalargs.toArray(new String[0]));
  72         OutputAnalyzer output = new OutputAnalyzer(pb.start());
  73         output.shouldHaveExitValue(0);
  74 
  75         String result = output.getStdout();
  76         return result;
  77     }
  78 
  79     public static void main(String[] args) throws Exception {
  80         String result;
  81 
  82         result = runTest("-XX:+G1PrintRegionLivenessInfo");
  83         // check that we got region statistics output
  84         if (result.indexOf("PHASE") == -1) {
  85             throw new RuntimeException("Unexpected output from -XX:+PrintRegionLivenessInfo found.");
  86         }
  87 
  88         result = runTest("-XX:-G1PrintRegionLivenessInfo");
  89         if (result.indexOf("remset") != -1) {
  90             throw new RuntimeException("Should find remembered set information in output.");
  91         }
  92     }
  93 }
  94 


  40 
  41 class RunAndWaitForMarking {
  42     public static void main(String[] args) {
  43         System.gc();
  44         try {
  45             Thread.sleep(200);
  46         } catch (InterruptedException e) {
  47         }
  48     }
  49 }
  50 
  51 public class TestPrintRegionRememberedSetInfo {
  52 
  53     public static String runTest(String arg) throws Exception {
  54         ArrayList<String> finalargs = new ArrayList<String>();
  55         String[] defaultArgs = new String[] {
  56             "-XX:+UseG1GC",
  57             "-Xmx10m",
  58             "-XX:+ExplicitGCInvokesConcurrent",
  59             "-XX:+UnlockDiagnosticVMOptions",

  60             "-XX:G1HeapRegionSize=1M",
  61             "-XX:InitiatingHeapOccupancyPercent=0",
  62         };
  63 
  64         finalargs.addAll(Arrays.asList(defaultArgs));
  65         finalargs.add(arg);
  66 
  67         finalargs.add(RunAndWaitForMarking.class.getName());
  68 
  69         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
  70             finalargs.toArray(new String[0]));
  71         OutputAnalyzer output = new OutputAnalyzer(pb.start());
  72         output.shouldHaveExitValue(0);
  73 
  74         String result = output.getStdout();
  75         return result;
  76     }
  77 
  78     public static void main(String[] args) throws Exception {
  79         String result;
  80 
  81         result = runTest("-Xlog:gc+liveness=trace");
  82         // check that we got region statistics output
  83         if (result.indexOf("PHASE") == -1) {
  84             throw new RuntimeException("Unexpected output from -XX:+PrintRegionLivenessInfo found.");
  85         }
  86 
  87         result = runTest("-Xlog:gc+liveness");
  88         if (result.indexOf("remset") != -1) {
  89             throw new RuntimeException("Should find remembered set information in output.");
  90         }
  91     }
  92 }
  93 
< prev index next >