use of com.tagtraum.perf.gcviewer.model.AbstractGCEvent in project GCViewer by chewiebug.
the class CSVDataWriter method write.
/**
* Writes the model and flushes the internal PrintWriter.
*/
public void write(GCModel model) throws IOException {
writeHeader();
Iterator<AbstractGCEvent<?>> i = model.getStopTheWorldEvents();
while (i.hasNext()) {
AbstractGCEvent<?> abstractGCEvent = i.next();
// filter "application stopped" events
if (abstractGCEvent instanceof GCEvent) {
GCEvent event = (GCEvent) abstractGCEvent;
// write always two lines so that there is a nice used memory curve
if (model.hasCorrectTimestamp()) {
// we have the timestamps therefore we can correct it with the pause time
out.print((event.getTimestamp() - event.getPause()));
} else {
out.print(event.getTimestamp());
}
out.print(',');
// pre
out.print(event.getPreUsed());
out.print(',');
out.print(event.getTotal());
out.print(',');
out.print(event.getPause());
out.print(',');
out.println(event.getExtendedType());
out.print(event.getTimestamp());
out.print(',');
// post
out.print(event.getPostUsed());
out.print(',');
out.print(event.getTotal());
out.print(',');
out.print(0);
out.print(',');
out.println("NONE");
}
}
out.flush();
}
use of com.tagtraum.perf.gcviewer.model.AbstractGCEvent in project GCViewer by chewiebug.
the class DataReaderSun1_2_2 method read.
public GCModel read() throws IOException {
if (getLogger().isLoggable(Level.INFO))
getLogger().info("Reading Sun 1.2.2 format...");
try {
GCModel model = new GCModel();
model.setFormat(GCModel.Format.SUN_1_2_2VERBOSE_GC);
String line = null;
boolean timeline = false;
AbstractGCEvent<GCEvent> lastEvent = new GCEvent();
GCEvent event = null;
while ((line = in.readLine()) != null && shouldContinue()) {
if (!timeline) {
if (line.endsWith("milliseconds since last GC>")) {
timeline = true;
double time = Integer.parseInt(line.substring(5, line.indexOf(' ', 5)));
event = new GCEvent();
event.setTimestamp(lastEvent.getTimestamp() + (time / 1000.0d));
}
} else {
timeline = false;
// we have a time, so now we expect a either expansion or freed objects
if (line.indexOf("expanded object space by") != -1) {
// expansion
int endIndex = line.indexOf(' ', "<GC: expanded object space by ".length());
//int incBy = Integer.parseInt(line.substring("<GC: expanded object space by ".length(), endIndex));
int beginIndex = endIndex + " to ".length();
int incTo = Integer.parseInt(line.substring(beginIndex, line.indexOf(' ', beginIndex)));
int percentUsed = Integer.parseInt(line.substring(line.length() - "XX% free>".length(), line.length() - "% free>".length()));
event.setPostUsed((int) ((incTo * percentUsed / 1024L / 100l)));
event.setPreUsed(event.getPostUsed());
event.setTotal((int) (incTo / 1024L));
event.setType(AbstractGCEvent.Type.GC);
event.setPause(0);
model.add(event);
lastEvent = event;
} else if (line.indexOf(" freed ") != -1 && line.indexOf(" objects, ") != -1) {
// freed objects
int startIndex = line.indexOf(',') + 2;
int endIndex = line.indexOf(' ', startIndex);
int freed = Integer.parseInt(line.substring(startIndex, endIndex));
startIndex = line.indexOf("in ") + 3;
endIndex = line.indexOf(' ', startIndex);
int pause = Integer.parseInt(line.substring(startIndex, endIndex));
startIndex = line.indexOf('(') + 1;
endIndex = line.indexOf('/', startIndex);
int postFree = Integer.parseInt(line.substring(startIndex, endIndex));
startIndex = line.indexOf('/') + 1;
endIndex = line.indexOf(')', startIndex);
int total = Integer.parseInt(line.substring(startIndex, endIndex));
event.setPostUsed((total - postFree) / 1024);
event.setPreUsed((total - postFree + freed) / 1024);
//event.setPostUsed(event.getPreUsed());
event.setTotal(total / 1024);
event.setType(AbstractGCEvent.Type.GC);
event.setPause((pause) / 1000.0d);
model.add(event);
lastEvent = event;
/*
event = new GCEvent();
event.setTimestamp(lastEvent.getTimestamp() + lastEvent.getPause());
event.setPostUsed((total - postFree) / 1024L);
event.setPreUsed(lastEvent.getPostUsed());
event.setTotal(total / 1024L);
event.setType(GCEvent.Type.GC);
event.setPause(0);
model.add(event);
lastEvent = event;
*/
} else {
// hm. what now...?
}
}
}
return model;
} finally {
if (in != null)
try {
in.close();
} catch (IOException ioe) {
}
if (getLogger().isLoggable(Level.INFO))
getLogger().info("Done reading.");
}
}
use of com.tagtraum.perf.gcviewer.model.AbstractGCEvent in project GCViewer by chewiebug.
the class DataReaderSun1_3_1 method parseLine.
protected AbstractGCEvent<GCEvent> parseLine(String line, ParseInformation pos) throws ParseException {
AbstractGCEvent<GCEvent> event = new GCEvent();
try {
event.setTimestamp(count);
count++;
StringTokenizer st = new StringTokenizer(line, " ,->()K\r\n");
String token = st.nextToken();
if (token.equals("Full") && st.nextToken().equals("GC")) {
event.setType(AbstractGCEvent.Type.FULL_GC);
} else if (token.equals("Inc") && st.nextToken().equals("GC")) {
event.setType(AbstractGCEvent.Type.INC_GC);
} else if (token.equals("GC")) {
event.setType(AbstractGCEvent.Type.GC);
} else {
throw new ParseException("Error parsing entry: " + line);
}
setMemoryAndPauses((GCEvent) event, line);
//System.out.println("Real : [" + line + "]");
return event;
} catch (RuntimeException rte) {
final ParseException parseException = new ParseException("Error parsing entry: " + line + ", " + rte.toString());
parseException.initCause(rte);
throw parseException;
}
}
use of com.tagtraum.perf.gcviewer.model.AbstractGCEvent in project GCViewer by chewiebug.
the class TotalTenuredRenderer method computePolygon.
public Polygon computePolygon(ModelChart modelChart, GCModel model) {
ScaledPolygon polygon = createMemoryScaledPolygon();
polygon.addPoint(0.0d, 0.0d);
double lastTotal = 0;
for (Iterator<AbstractGCEvent<?>> i = model.getStopTheWorldEvents(); i.hasNext(); ) {
AbstractGCEvent<?> abstractGCEvent = i.next();
if (abstractGCEvent instanceof GCEvent) {
GCEvent event = (GCEvent) abstractGCEvent;
GCEvent tenured = event.getTenured();
if (hasMemoryInformation(event) && tenured != null) {
if (polygon.npoints == 1) {
// first point needs to be treated different from the rest,
// because otherwise the polygon would not start with a vertical line at 0,
// but with a slanting line between 0 and after the first pause
polygon.addPoint(0, (double) tenured.getTotal());
}
polygon.addPoint(tenured.getTimestamp() - model.getFirstPauseTimeStamp() + event.getPause(), tenured.getTotal());
lastTotal = tenured.getTotal();
}
}
}
polygon.addPointNotOptimised(model.getRunningTime(), lastTotal);
polygon.addPointNotOptimised(model.getRunningTime(), 0.0d);
return polygon;
}
use of com.tagtraum.perf.gcviewer.model.AbstractGCEvent in project GCViewer by chewiebug.
the class UsedHeapRenderer method computePolygon.
public Polygon computePolygon(ModelChart modelChart, GCModel model) {
ScaledPolygon polygon = createMemoryScaledPolygon();
for (Iterator<AbstractGCEvent<?>> i = model.getStopTheWorldEvents(); i.hasNext(); ) {
AbstractGCEvent<?> abstractGCEvent = i.next();
if (abstractGCEvent instanceof GCEvent) {
GCEvent event = (GCEvent) abstractGCEvent;
// e.g. "GC remark" of G1 algorithm does not contain memory information
if (event.getTotal() > 0) {
final double timestamp = event.getTimestamp() - model.getFirstPauseTimeStamp();
polygon.addPoint(timestamp, event.getPreUsed());
polygon.addPoint(timestamp + event.getPause(), event.getPostUsed());
}
}
}
// dummy point to make the polygon complete
polygon.addPoint(model.getRunningTime(), 0.0d);
//System.out.println("last x coord " + polygon.xpoints[polygon.npoints-1]);
return polygon;
}
Aggregations