50
51 public static void main(String[] args) {
52 if ( args == null || args.length == 0 ){
53 startMeWithArgs();
54 } else {
55 doTestOfTwoTimSorts(Integer.parseInt(args[0]));
56 }
57 }
58
59 private static void startMeWithArgs(){
60 /*
61 * big tests not for regular execution on all platforms:
62 * run main/othervm -Xmx8g TimSortStackSize2 1073741824
63 * run main/othervm -Xmx16g TimSortStackSize2 2147483644
64 */
65 try {
66 Boolean compressedOops = WhiteBox.getWhiteBox()
67 .getBooleanVMFlag("UseCompressedOops");
68 long memory = (compressedOops == null || compressedOops) ? 385 : 770;
69 final String xmsValue = "-Xms" + memory + "m";
70 final String xmxValue = "-Xmx" + memory + "m";
71
72 System.out.printf("compressedOops: %s; Test will be started with \"%s %s\"%n",
73 compressedOops, xmsValue, xmxValue);
74 ProcessBuilder processBuilder = ProcessTools
75 .createJavaProcessBuilder(Utils.addTestJavaOpts(xmsValue, xmxValue,
76 "TimSortStackSize2", "67108864"
77 )
78 );
79 OutputAnalyzer output = ProcessTools.executeProcess(processBuilder);
80 System.out.println(output.getOutput());
81 output.shouldHaveExitValue(0);
82 } catch( Exception e ){
83 e.printStackTrace();
84 throw new RuntimeException(e);
85 }
86 }
87
88 private static void doTestOfTwoTimSorts(final int lengthOfTest){
89 boolean passed = doTest("TimSort", lengthOfTest,
90 (Integer [] a) -> Arrays.sort(a));
91 passed = doTest("ComparableTimSort", lengthOfTest, (Integer [] a) ->
92 Arrays.sort(a, (Object first, Object second) -> {
93 return ((Comparable<Object>)first).compareTo(second);
94 }))
95 && passed;
96 if ( !passed ){
97 throw new RuntimeException();
98 }
99 }
100
101 private static boolean doTest(final String msg, final int lengthOfTest,
102 final Consumer<Integer[]> c){
|
50
51 public static void main(String[] args) {
52 if ( args == null || args.length == 0 ){
53 startMeWithArgs();
54 } else {
55 doTestOfTwoTimSorts(Integer.parseInt(args[0]));
56 }
57 }
58
59 private static void startMeWithArgs(){
60 /*
61 * big tests not for regular execution on all platforms:
62 * run main/othervm -Xmx8g TimSortStackSize2 1073741824
63 * run main/othervm -Xmx16g TimSortStackSize2 2147483644
64 */
65 try {
66 Boolean compressedOops = WhiteBox.getWhiteBox()
67 .getBooleanVMFlag("UseCompressedOops");
68 long memory = (compressedOops == null || compressedOops) ? 385 : 770;
69 final String xmsValue = "-Xms" + memory + "m";
70 final String xmxValue = "-Xmx" + 2 * memory + "m";
71
72 System.out.printf("compressedOops: %s; Test will be started with \"%s %s\"%n",
73 compressedOops, xmsValue, xmxValue);
74 OutputAnalyzer output = ProcessTools.executeTestJvm(xmsValue,
75 xmxValue,
76 "TimSortStackSize2",
77 "67108864");
78 System.out.println(output.getOutput());
79 output.shouldHaveExitValue(0);
80 } catch (Exception e) {
81 e.printStackTrace();
82 throw new RuntimeException(e);
83 }
84 }
85
86 private static void doTestOfTwoTimSorts(final int lengthOfTest){
87 boolean passed = doTest("TimSort", lengthOfTest,
88 (Integer [] a) -> Arrays.sort(a));
89 passed = doTest("ComparableTimSort", lengthOfTest, (Integer [] a) ->
90 Arrays.sort(a, (Object first, Object second) -> {
91 return ((Comparable<Object>)first).compareTo(second);
92 }))
93 && passed;
94 if ( !passed ){
95 throw new RuntimeException();
96 }
97 }
98
99 private static boolean doTest(final String msg, final int lengthOfTest,
100 final Consumer<Integer[]> c){
|