Skip to content

Commit 06b2df7

Browse files
committed
Adds totalPermAllocMax, totalPermUsedMax, and
totalPermUsedMaxpc to the Summary output. Example: totalPermAllocMax; 512; M totalPermUsedMax; 103.398; M totalPermUsedMaxpc; 20.2; %
1 parent 7db04c2 commit 06b2df7

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

src/main/java/com/tagtraum/perf/gcviewer/exp/impl/SummaryDataWriter.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,18 @@ private void exportMemorySummary(PrintWriter out, GCModel model) {
266266
exportValue(out, "totalYoungUsedMaxpc", percentFormatter.format(model.getYoungUsedSizes().getMax() * 100.0 / model.getYoungAllocatedSizes().getMax()), "%");
267267
}
268268

269+
if (model.getPermAllocatedSizes().getN() == 0) {
270+
exportValue(out, "totalPermAllocMax", "n/a", "M");
271+
exportValue(out, "totalPermUsedMax", "n/a", "M");
272+
exportValue(out, "totalPermUsedMaxpc", "n/a", "%");
273+
} else {
274+
formed = footprintFormatter.formatToFormatted(model.getPermAllocatedSizes().getMax());
275+
exportValue(out, "totalPermAllocMax", formed.getValue(), formed.getUnits());
276+
formed = footprintFormatter.formatToFormatted(model.getPermUsedSizes().getMax());
277+
exportValue(out, "totalPermUsedMax", formed.getValue(), formed.getUnits());
278+
exportValue(out, "totalPermUsedMaxpc", percentFormatter.format(model.getPermUsedSizes().getMax() * 100.0 / model.getPermAllocatedSizes().getMax()), "%");
279+
}
280+
269281
// check whether we have full gc data at all
270282
final boolean fullGCDataVailable = model.getFootprintAfterFullGC().getN() != 0;
271283
final boolean fullGCSlopeDataVailable = model.getFootprintAfterFullGC().getN() > 1;

src/test/java/com/tagtraum/perf/gcviewer/exp/SummaryDataWriterTest.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@
66
import java.io.IOException;
77
import java.net.MalformedURLException;
88
import java.net.URL;
9+
import java.text.NumberFormat;
910

1011
import com.tagtraum.perf.gcviewer.exp.impl.SummaryDataWriter;
1112
import com.tagtraum.perf.gcviewer.model.AbstractGCEvent.Type;
1213
import com.tagtraum.perf.gcviewer.model.GCEvent;
1314
import com.tagtraum.perf.gcviewer.model.GCModel;
15+
import com.tagtraum.perf.gcviewer.util.MemoryFormat;
16+
1417
import org.hamcrest.Matchers;
18+
import org.junit.BeforeClass;
1519
import org.junit.Test;
1620

1721
/**
@@ -21,6 +25,17 @@
2125
*/
2226
public class SummaryDataWriterTest {
2327

28+
private static NumberFormat percentFormatter;
29+
private static MemoryFormat memoryFormatter;
30+
31+
@BeforeClass
32+
public static void setupClass() {
33+
percentFormatter = NumberFormat.getInstance();
34+
percentFormatter.setMaximumFractionDigits(1);
35+
percentFormatter.setMinimumFractionDigits(1);
36+
memoryFormatter = new MemoryFormat();
37+
}
38+
2439
private GCModel createGcModel() throws MalformedURLException {
2540
GCModel model = new GCModel();
2641
model.setURL(new URL("file", "localhost", "test-file"));
@@ -73,4 +88,28 @@ public void testWriteWithFullGc() throws IOException {
7388

7489
assertThat("totalHeapAllocMax", csv, Matchers.containsString("avgfootprintAfterFullGC; 724; K"));
7590
}
91+
92+
@Test
93+
public void testWriteWithPerm() throws IOException {
94+
ByteArrayOutputStream output = new ByteArrayOutputStream();
95+
SummaryDataWriter objectUnderTest = new SummaryDataWriter(output);
96+
97+
// 83.403: [Full GC 83.403: [Tenured: 38156K->54636K(349568K), 0.6013150 secs] 141564K->54636K(506944K), [Perm : 73727K->73727K(73728K)], 0.6014256 secs] [Times: user=0.58 sys=0.00, real=0.59 secs]
98+
GCEvent fullGcEvent = new GCEvent(83.403, 141564, 54636, 506944, 0.6014256, Type.FULL_GC);
99+
GCEvent tenured = new GCEvent(83.403, 38156, 54636, 349568, 0.6013150, Type.TENURED);
100+
GCEvent perm = new GCEvent(83.403, 73727, 73727, 73728, 0.6014256, Type.PERM);
101+
fullGcEvent.add(tenured);
102+
fullGcEvent.add(perm);
103+
104+
GCModel model = createGcModel();
105+
model.add(fullGcEvent);
106+
107+
objectUnderTest.write(model);
108+
109+
String csv = output.toString();
110+
111+
assertThat("totalPermAllocMax", csv, Matchers.containsString("totalPermAllocMax; 72; M"));
112+
assertThat("totalPermUsedMax", csv, Matchers.containsString("totalPermUsedMax; " + memoryFormatter.formatToFormatted(73727).getValue() + "; M"));
113+
assertThat("totalPermUsedMaxpc", csv, Matchers.containsString("totalPermUsedMaxpc; " + percentFormatter.format(100.0) + "; %"));
114+
}
76115
}

0 commit comments

Comments
 (0)