< prev index next >

test/gc/g1/plab/lib/PLABUtils.java

Print this page


   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  */
  23 package gc.g1.plab.lib;
  24 
  25 import java.util.ArrayList;
  26 import java.util.Arrays;
  27 import java.util.Collections;
  28 import java.util.List;
  29 import jdk.test.lib.Utils;
  30 
  31 /**
  32  * Utilities for PLAB testing.
  33  */
  34 public class PLABUtils {
  35 
  36     /**
  37      * List of VM options for GC tuning.
  38      */
  39     private final static String[] GC_TUNE_OPTIONS = {
  40         "-XX:+UseG1GC",

  41         "-XX:OldSize=64m",
  42         "-XX:-UseAdaptiveSizePolicy",
  43         "-XX:-UseTLAB",
  44         "-XX:SurvivorRatio=1"
  45     };
  46 
  47     /**
  48      * List of options for GC logging.
  49      */
  50     private final static String G1_PLAB_LOGGING_OPTIONS[] = {
  51         "-XX:+PrintPLAB",
  52         "-XX:+PrintGC"
  53     };
  54 
  55     /**
  56      * List of options for WhiteBox using.
  57      */
  58     private final static String WB_DIAGNOSTIC_OPTIONS[] = {
  59         "-Xbootclasspath/a:.",
  60         "-XX:+UnlockDiagnosticVMOptions",
  61         "-XX:+WhiteBoxAPI"
  62     };
  63 
  64     /**
  65      * Prepares options for testing.
  66      *
  67      * @param options - additional options for testing
  68      * @return List of options
  69      */
  70     public static List<String> prepareOptions(String... options) {
  71         if (options == null) {
  72             throw new IllegalArgumentException("Options cannot be null");
  73         }
  74         List<String> executionOtions = new ArrayList<>(
  75                 Arrays.asList(Utils.getTestJavaOpts())
  76         );
  77         Collections.addAll(executionOtions, WB_DIAGNOSTIC_OPTIONS);
  78         Collections.addAll(executionOtions, G1_PLAB_LOGGING_OPTIONS);
  79         Collections.addAll(executionOtions, GC_TUNE_OPTIONS);
  80         Collections.addAll(executionOtions, options);
  81         return executionOtions;
  82     }
  83 }
   1 /*
   2  * Copyright (c) 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  */
  23 package gc.g1.plab.lib;
  24 
  25 import java.util.ArrayList;
  26 import java.util.Arrays;
  27 import java.util.Collections;
  28 import java.util.List;
  29 import jdk.test.lib.Utils;
  30 
  31 /**
  32  * Utilities for PLAB testing.
  33  */
  34 public class PLABUtils {
  35 
  36     /**
  37      * PLAB tests default options list
  38      */
  39     private final static String[] GC_TUNE_OPTIONS = {
  40         "-XX:+UseG1GC",
  41         "-XX:G1HeapRegionSize=1m",
  42         "-XX:OldSize=64m",
  43         "-XX:-UseAdaptiveSizePolicy",
  44         "-XX:-UseTLAB",
  45         "-XX:SurvivorRatio=1"
  46     };
  47 
  48     /**
  49      * GC logging options list.
  50      */
  51     private final static String G1_PLAB_LOGGING_OPTIONS[] = {
  52         "-Xlog:gc=debug,gc+plab=debug"

  53     };
  54 
  55     /**
  56      * List of options required to use WhiteBox.
  57      */
  58     private final static String WB_DIAGNOSTIC_OPTIONS[] = {
  59         "-Xbootclasspath/a:.",
  60         "-XX:+UnlockDiagnosticVMOptions",
  61         "-XX:+WhiteBoxAPI"
  62     };
  63 
  64     /**
  65      * Prepares options for testing.
  66      *
  67      * @param options - additional options for testing
  68      * @return List of options
  69      */
  70     public static List<String> prepareOptions(List<String> options) {
  71         if (options == null) {
  72             throw new IllegalArgumentException("Options cannot be null");
  73         }
  74         List<String> executionOtions = new ArrayList<>(
  75                 Arrays.asList(Utils.getTestJavaOpts())
  76         );
  77         Collections.addAll(executionOtions, WB_DIAGNOSTIC_OPTIONS);
  78         Collections.addAll(executionOtions, G1_PLAB_LOGGING_OPTIONS);
  79         Collections.addAll(executionOtions, GC_TUNE_OPTIONS);
  80         executionOtions.addAll(options);
  81         return executionOtions;
  82     }
  83 }
< prev index next >