Skip to content

Commit 2dbf9c1

Browse files
committed
Merge remote-tracking branch 'amcrn/enh/promotion-summary' into develop
# Conflicts: # src/test/java/com/tagtraum/perf/gcviewer/exp/SummaryDataWriterTest.java
2 parents 1bab7ec + 129829d commit 2dbf9c1

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,19 @@ private void exportMemorySummary(PrintWriter out, GCModel model) {
361361
exportValue(out, "avgFreedMemoryByGCisSig", isSignificant(model.getFreedMemoryByGC().average(),
362362
model.getFreedMemoryByGC().standardDeviation()));
363363
}
364+
365+
final boolean promotionDataAvailable = model.getPromotion().getN() != 0;
366+
367+
if (!promotionDataAvailable) {
368+
exportValue(out, "avgPromotion", "n.a.", "M");
369+
exportValue(out, "promotionTotal", "n.a.", "M");
370+
}
371+
else {
372+
formed = footprintFormatter.formatToFormatted(model.getPromotion().average());
373+
exportValue(out, "avgPromotion", formed.getValue(), formed.getUnits());
374+
formed = footprintFormatter.formatToFormatted(model.getPromotion().getSum());
375+
exportValue(out, "promotionTotal", formed.getValue(), formed.getUnits());
376+
}
364377
}
365378

366379
private FormattedValue sigmaMemoryFormat(double value) {

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,21 @@
22

33
import static org.junit.Assert.assertThat;
44

5+
import java.io.ByteArrayInputStream;
56
import java.io.ByteArrayOutputStream;
67
import java.io.IOException;
78
import java.net.MalformedURLException;
89
import java.net.URL;
910
import java.text.NumberFormat;
1011

1112
import com.tagtraum.perf.gcviewer.exp.impl.SummaryDataWriter;
13+
import com.tagtraum.perf.gcviewer.imp.DataReader;
14+
import com.tagtraum.perf.gcviewer.imp.DataReaderSun1_6_0;
15+
import com.tagtraum.perf.gcviewer.imp.GcLogType;
1216
import com.tagtraum.perf.gcviewer.model.AbstractGCEvent.Type;
1317
import com.tagtraum.perf.gcviewer.model.GCEvent;
1418
import com.tagtraum.perf.gcviewer.model.GCModel;
19+
import com.tagtraum.perf.gcviewer.model.GcResourceFile;
1520
import com.tagtraum.perf.gcviewer.util.MemoryFormat;
1621

1722
import org.hamcrest.Matchers;
@@ -112,4 +117,27 @@ public void testWriteWithPerm() throws IOException {
112117
assertThat("totalPermUsedMax", csv, Matchers.containsString("totalPermUsedMax; " + memoryFormatter.formatToFormatted(73727).getValue() + "; M"));
113118
assertThat("totalPermUsedMaxpc", csv, Matchers.containsString("totalPermUsedMaxpc; " + percentFormatter.format(100.0) + "; %"));
114119
}
120+
121+
@Test
122+
public void testWriteWithPromotion() throws IOException {
123+
ByteArrayInputStream in = new ByteArrayInputStream(
124+
("2011-01-25T17:10:16.889+0100: 12076.859: [GC 12076.859: [ParNew2011-01-25T17:10:16.896+0100: 12076.866: [CMS-concurrent-abortable-preclean: 0.929/4.899 secs] [Times: user=2.13 sys=0.04, real=4.90 secs]" +
125+
"\n" +
126+
"\nDesired survivor size 720896 bytes, new threshold 1 (max 4)" +
127+
"\n- age 1: 1058016 bytes, 1058016 total" +
128+
"\n: 13056K->1408K(13056K), 0.0128277 secs] 131480K->122757K(141328K), 0.0131346 secs] [Times: user=0.15 sys=0.00, real=0.01 secs]")
129+
.getBytes());
130+
DataReader reader = new DataReaderSun1_6_0(new GcResourceFile("byteArray"), in, GcLogType.SUN1_6);
131+
GCModel model = reader.read();
132+
model.setURL(new URL("file", "localhost", "test-file"));
133+
134+
ByteArrayOutputStream output = new ByteArrayOutputStream();
135+
SummaryDataWriter objectUnderTest = new SummaryDataWriter(output);
136+
137+
objectUnderTest.write(model);
138+
139+
String csv = output.toString();
140+
141+
assertThat("avgPromotion", csv, Matchers.containsString("avgPromotion; " + memoryFormatter.formatToFormatted(2925).getValue() + "; K"));
142+
}
115143
}

0 commit comments

Comments
 (0)