Skip to content

Commit

Permalink
Add Promotion Avg & Total To Summary
Browse files Browse the repository at this point in the history
Adds avgPromotion and promotionTotal to the Summary output.

Example:

    avgPromotion; 2,925; K
    promotionTotal; 3,820; M
  • Loading branch information
amcrn committed Aug 1, 2018
1 parent 7db04c2 commit 129829d
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,19 @@ private void exportMemorySummary(PrintWriter out, GCModel model) {
exportValue(out, "avgFreedMemoryByGCisSig", isSignificant(model.getFreedMemoryByGC().average(),
model.getFreedMemoryByGC().standardDeviation()));
}

final boolean promotionDataAvailable = model.getPromotion().getN() != 0;

if (!promotionDataAvailable) {
exportValue(out, "avgPromotion", "n.a.", "M");
exportValue(out, "promotionTotal", "n.a.", "M");
}
else {
formed = footprintFormatter.formatToFormatted(model.getPromotion().average());
exportValue(out, "avgPromotion", formed.getValue(), formed.getUnits());
formed = footprintFormatter.formatToFormatted(model.getPromotion().getSum());
exportValue(out, "promotionTotal", formed.getValue(), formed.getUnits());
}
}

private FormattedValue sigmaMemoryFormat(double value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,25 @@

import static org.junit.Assert.assertThat;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.NumberFormat;

import com.tagtraum.perf.gcviewer.exp.impl.SummaryDataWriter;
import com.tagtraum.perf.gcviewer.imp.DataReader;
import com.tagtraum.perf.gcviewer.imp.DataReaderSun1_6_0;
import com.tagtraum.perf.gcviewer.imp.GcLogType;
import com.tagtraum.perf.gcviewer.model.AbstractGCEvent.Type;
import com.tagtraum.perf.gcviewer.model.GCEvent;
import com.tagtraum.perf.gcviewer.model.GCModel;
import com.tagtraum.perf.gcviewer.model.GcResourceFile;
import com.tagtraum.perf.gcviewer.util.MemoryFormat;

import org.hamcrest.Matchers;
import org.junit.BeforeClass;
import org.junit.Test;

/**
Expand All @@ -21,6 +30,17 @@
*/
public class SummaryDataWriterTest {

private static NumberFormat percentFormatter;
private static MemoryFormat memoryFormatter;

@BeforeClass
public static void setupClass() {
percentFormatter = NumberFormat.getInstance();
percentFormatter.setMaximumFractionDigits(1);
percentFormatter.setMinimumFractionDigits(1);
memoryFormatter = new MemoryFormat();
}

private GCModel createGcModel() throws MalformedURLException {
GCModel model = new GCModel();
model.setURL(new URL("file", "localhost", "test-file"));
Expand Down Expand Up @@ -73,4 +93,27 @@ public void testWriteWithFullGc() throws IOException {

assertThat("totalHeapAllocMax", csv, Matchers.containsString("avgfootprintAfterFullGC; 724; K"));
}

@Test
public void testWriteWithPromotion() throws IOException {
ByteArrayInputStream in = new ByteArrayInputStream(
("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]" +
"\n" +
"\nDesired survivor size 720896 bytes, new threshold 1 (max 4)" +
"\n- age 1: 1058016 bytes, 1058016 total" +
"\n: 13056K->1408K(13056K), 0.0128277 secs] 131480K->122757K(141328K), 0.0131346 secs] [Times: user=0.15 sys=0.00, real=0.01 secs]")
.getBytes());
DataReader reader = new DataReaderSun1_6_0(new GcResourceFile("byteArray"), in, GcLogType.SUN1_6);
GCModel model = reader.read();
model.setURL(new URL("file", "localhost", "test-file"));

ByteArrayOutputStream output = new ByteArrayOutputStream();
SummaryDataWriter objectUnderTest = new SummaryDataWriter(output);

objectUnderTest.write(model);

String csv = output.toString();

assertThat("avgPromotion", csv, Matchers.containsString("avgPromotion; " + memoryFormatter.formatToFormatted(2925).getValue() + "; K"));
}
}

0 comments on commit 129829d

Please sign in to comment.