Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Promotion Avg & Total To Summary #203

Merged
merged 1 commit into from
Aug 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"));
}
}