76 checkLogValue(output);
77
78 output.shouldHaveExitValue(0);
79 }
80
81 // Find the first Reference Processing log and check its format.
82 public static void checkLogFormat(OutputAnalyzer output, boolean parallelRefProcEnabled) {
83 String countRegex = "[0-9]+";
84 String timeRegex = doubleRegex + "ms";
85 String totalRegex = gcLogTimeRegex + indent(4) + referenceProcessing + ": " + timeRegex + "\n";
86 String balanceRegex = parallelRefProcEnabled ? gcLogTimeRegex + indent(8) + "Balance queues: " + timeRegex + "\n" : "";
87 String softRefRegex = gcLogTimeRegex + indent(6) + softReference + ": " + timeRegex + "\n";
88 String weakRefRegex = gcLogTimeRegex + indent(6) + weakReference + ": " + timeRegex + "\n";
89 String finalRefRegex = gcLogTimeRegex + indent(6) + finalReference + ": " + timeRegex + "\n";
90 String phantomRefRegex = gcLogTimeRegex + indent(6) + phantomReference + ": " + timeRegex + "\n";
91 String refDetailRegex = gcLogTimeRegex + indent(8) + phase2 + ": " + timeRegex + "\n" +
92 gcLogTimeRegex + indent(8) + phase3 + ": " + timeRegex + "\n" +
93 gcLogTimeRegex + indent(8) + "Discovered: " + countRegex + "\n" +
94 gcLogTimeRegex + indent(8) + "Cleared: " + countRegex + "\n";
95 String softRefDetailRegex = gcLogTimeRegex + indent(8) + phase1 + ": " + timeRegex + "\n" + refDetailRegex;
96 String enqueueRegex = gcLogTimeRegex + indent(4) + "Reference Enqueuing: " + timeRegex + "\n";
97 String enqueueDetailRegex = gcLogTimeRegex + indent(6) + "Reference Counts: Soft: " + countRegex +
98 " Weak: " + countRegex + " Final: " + countRegex + " Phantom: " + countRegex + "\n";
99
100 output.shouldMatch(/* Total Reference processing time */
101 totalRegex +
102 /* SoftReference processing */
103 softRefRegex + balanceRegex + softRefDetailRegex +
104 /* WeakReference processing */
105 weakRefRegex + balanceRegex + refDetailRegex +
106 /* FinalReference processing */
107 finalRefRegex + balanceRegex + refDetailRegex +
108 /* PhantomReference processing */
109 phantomRefRegex + balanceRegex + refDetailRegex +
110 /* Total Enqueuing time */
111 enqueueRegex +
112 /* Enqueued Stats */
113 enqueueDetailRegex
114 );
115 }
116
117 // After getting time value, update 'output' for next use.
118 public static BigDecimal getTimeValue(String name, int indentCount) {
119 // Pattern of 'name', 'value' and some extra strings.
120 String patternString = gcLogTimeRegex + indent(indentCount) + name + ": " + "(" + doubleRegex + ")";
121 Matcher m = Pattern.compile(patternString).matcher(output);
122 if (!m.find()) {
123 throw new RuntimeException("Could not find time log for " + patternString);
124 }
125
126 String match = m.group();
127 String value = m.group(1);
128
129 double result = Double.parseDouble(value);
130
131 int index = output.indexOf(match);
132 if (index != -1) {
133 output = output.substring(index, output.length());
|
76 checkLogValue(output);
77
78 output.shouldHaveExitValue(0);
79 }
80
81 // Find the first Reference Processing log and check its format.
82 public static void checkLogFormat(OutputAnalyzer output, boolean parallelRefProcEnabled) {
83 String countRegex = "[0-9]+";
84 String timeRegex = doubleRegex + "ms";
85 String totalRegex = gcLogTimeRegex + indent(4) + referenceProcessing + ": " + timeRegex + "\n";
86 String balanceRegex = parallelRefProcEnabled ? gcLogTimeRegex + indent(8) + "Balance queues: " + timeRegex + "\n" : "";
87 String softRefRegex = gcLogTimeRegex + indent(6) + softReference + ": " + timeRegex + "\n";
88 String weakRefRegex = gcLogTimeRegex + indent(6) + weakReference + ": " + timeRegex + "\n";
89 String finalRefRegex = gcLogTimeRegex + indent(6) + finalReference + ": " + timeRegex + "\n";
90 String phantomRefRegex = gcLogTimeRegex + indent(6) + phantomReference + ": " + timeRegex + "\n";
91 String refDetailRegex = gcLogTimeRegex + indent(8) + phase2 + ": " + timeRegex + "\n" +
92 gcLogTimeRegex + indent(8) + phase3 + ": " + timeRegex + "\n" +
93 gcLogTimeRegex + indent(8) + "Discovered: " + countRegex + "\n" +
94 gcLogTimeRegex + indent(8) + "Cleared: " + countRegex + "\n";
95 String softRefDetailRegex = gcLogTimeRegex + indent(8) + phase1 + ": " + timeRegex + "\n" + refDetailRegex;
96
97 output.shouldMatch(/* Total Reference processing time */
98 totalRegex +
99 /* SoftReference processing */
100 softRefRegex + balanceRegex + softRefDetailRegex +
101 /* WeakReference processing */
102 weakRefRegex + balanceRegex + refDetailRegex +
103 /* FinalReference processing */
104 finalRefRegex + balanceRegex + refDetailRegex +
105 /* PhantomReference processing */
106 phantomRefRegex + balanceRegex + refDetailRegex
107 );
108 }
109
110 // After getting time value, update 'output' for next use.
111 public static BigDecimal getTimeValue(String name, int indentCount) {
112 // Pattern of 'name', 'value' and some extra strings.
113 String patternString = gcLogTimeRegex + indent(indentCount) + name + ": " + "(" + doubleRegex + ")";
114 Matcher m = Pattern.compile(patternString).matcher(output);
115 if (!m.find()) {
116 throw new RuntimeException("Could not find time log for " + patternString);
117 }
118
119 String match = m.group();
120 String value = m.group(1);
121
122 double result = Double.parseDouble(value);
123
124 int index = output.indexOf(match);
125 if (index != -1) {
126 output = output.substring(index, output.length());
|