Skip to content

Commit 047331b

Browse files
committed
update G1 parser to support Java 7
1 parent ee7706c commit 047331b

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

src/main/java/com/tagtraum/perf/gcviewer/imp/DataReaderSun1_6_0G1.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public class DataReaderSun1_6_0G1 extends AbstractDataReaderSun {
2323

2424
private static Logger LOG = Logger.getLogger(DataReaderSun1_6_0G1.class .getName());
2525

26+
private static final String TIMES = "[Times";
27+
2628
// the following pattern is specific for G1 with -XX:+PrintGCDetails
2729
// "0.295: [GC pause (young), 0.00594747 secs]"
2830
private static final Pattern PATTERN_GC_PAUSE = Pattern.compile("^([0-9.]+)[: \\[]{3}([A-Za-z- ()]+)[, ]+([0-9.]+)[ sec\\]]+$");
@@ -145,7 +147,7 @@ else if (line.indexOf(HEAP_SIZING_START) >= 0) {
145147
lineNumber = skipHeapSizes(in, parsePosition, lineNumber, HEAP_STRINGS);
146148
continue;
147149
}
148-
else if (line.indexOf("Times") < 0) {
150+
else if (line.indexOf(TIMES) < 0) {
149151
model.add(parseLine(line, parsePosition));
150152
}
151153
}
@@ -166,7 +168,7 @@ else if (beginningOfLine != null) {
166168
}
167169

168170
}
169-
if (line.indexOf("Times") >= 0) {
171+
if (line.indexOf(TIMES) >= 0) {
170172
// detailed gc description ends with " [Times: user=...]" -> finalize gcEvent
171173
// otherwise just ignore
172174
if (gcEvent != null) {

src/test/java/com/tagtraum/perf/gcviewer/imp/TestDataReaderSun1_6_0G1.java

+13
Original file line numberDiff line numberDiff line change
@@ -249,4 +249,17 @@ public void testRemark() throws Exception {
249249
assertEquals("memory", 0, model.getFreedMemoryByGC().getMax());
250250
}
251251

252+
public void testYoungJ7() throws Exception {
253+
TestLogHandler handler = new TestLogHandler();
254+
IMP_LOGGER.addHandler(handler);
255+
DATA_READER_FACTORY_LOGGER.addHandler(handler);
256+
257+
final InputStream in = getClass().getResourceAsStream("SampleSun1_7_0G1_Young.txt");
258+
final DataReader reader = new DataReaderSun1_6_0G1(in);
259+
GCModel model = reader.read();
260+
261+
assertEquals("gc pause", 0.00631825, model.getPause().getMax(), 0.000000001);
262+
assertEquals("heap", 64*1024, model.getHeapAllocatedSizes().getMax());
263+
}
264+
252265
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
0.134: [GC pause (young), 0.00631825 secs]
2+
[Parallel Time: 6.2 ms]
3+
[GC Worker Start Time (ms): 134.5 134.5 134.5 134.5
4+
Avg: 134.5, Min: 134.5, Max: 134.5, Diff: 0.0]
5+
[Update RS (ms): 0.0 0.0 0.0 0.0
6+
Avg: 0.0, Min: 0.0, Max: 0.0, Diff: 0.0]
7+
[Processed Buffers : 0 0 0 8
8+
Sum: 8, Avg: 2, Min: 0, Max: 8, Diff: 8]
9+
[Ext Root Scanning (ms): 0.6 0.6 0.6 0.4
10+
Avg: 0.6, Min: 0.4, Max: 0.6, Diff: 0.3]
11+
[Mark Stack Scanning (ms): 0.0 0.0 0.0 0.0
12+
Avg: 0.0, Min: 0.0, Max: 0.0, Diff: 0.0]
13+
[Scan RS (ms): 0.0 0.0 0.0 0.0
14+
Avg: 0.0, Min: 0.0, Max: 0.0, Diff: 0.0]
15+
[Object Copy (ms): 5.4 5.4 5.4 5.6
16+
Avg: 5.4, Min: 5.4, Max: 5.6, Diff: 0.2]
17+
[Termination (ms): 0.0 0.0 0.1 0.0
18+
Avg: 0.0, Min: 0.0, Max: 0.1, Diff: 0.1]
19+
[Termination Attempts : 1 1 1 1
20+
Sum: 4, Avg: 1, Min: 1, Max: 1, Diff: 0]
21+
[GC Worker End Time (ms): 140.6 140.6 140.6 140.7
22+
Avg: 140.6, Min: 140.6, Max: 140.7, Diff: 0.0]
23+
[GC Worker Times (ms): 6.1 6.1 6.1 6.1
24+
Avg: 6.1, Min: 6.1, Max: 6.1, Diff: 0.0]
25+
[Other: 0.1 ms]
26+
[Clear CT: 0.0 ms]
27+
[Other: 0.1 ms]
28+
[Choose CSet: 0.0 ms]
29+
[ 8192K->8128K(64M)]
30+
[Times: user=0.03 sys=0.02, real=0.01 secs]

0 commit comments

Comments
 (0)