Search in sources :

Example 6 with AbstractGCEvent

use of com.tagtraum.perf.gcviewer.model.AbstractGCEvent in project GCViewer by chewiebug.

the class UsedYoungRenderer method computePolygon.

@Override
public Polygon computePolygon(ModelChart modelChart, GCModel model) {
    ScaledPolygon polygon = createMemoryScaledPolygon();
    GCEvent lastTenuredEvent = null;
    GCEvent tenuredEvent = null;
    for (Iterator<AbstractGCEvent<?>> i = model.getStopTheWorldEvents(); i.hasNext(); ) {
        AbstractGCEvent<?> abstractGCEvent = i.next();
        if (abstractGCEvent instanceof GCEvent) {
            GCEvent event = (GCEvent) abstractGCEvent;
            GCEvent youngEvent = event.getYoung();
            int lastTenuredTotal = 0;
            int tenuredTotal = 0;
            if (youngEvent != null) {
                // event contains information about generation (only with -XX:+PrintGCDetails)
                if (modelChart.isShowTenured()) {
                    if (tenuredEvent != null && tenuredEvent.getTotal() > 0) {
                        lastTenuredEvent = tenuredEvent;
                    }
                    if (lastTenuredEvent == null)
                        lastTenuredEvent = event.getTenured();
                    tenuredEvent = event.getTenured();
                    lastTenuredTotal = lastTenuredEvent.getTotal();
                    tenuredTotal = tenuredEvent.getTotal();
                }
                // e.g. "GC remark" of G1 algorithm does not contain memory information
                if (youngEvent.getTotal() > 0) {
                    final double timestamp = event.getTimestamp() - model.getFirstPauseTimeStamp();
                    polygon.addPoint(timestamp, lastTenuredTotal + youngEvent.getPreUsed());
                    polygon.addPoint(timestamp + event.getPause(), tenuredTotal + youngEvent.getPostUsed());
                }
            }
        }
    }
    // dummy point to make the polygon complete
    polygon.addPoint(model.getRunningTime(), 0.0d);
    return polygon;
}
Also used : AbstractGCEvent(com.tagtraum.perf.gcviewer.model.AbstractGCEvent) GCEvent(com.tagtraum.perf.gcviewer.model.GCEvent) AbstractGCEvent(com.tagtraum.perf.gcviewer.model.AbstractGCEvent) Paint(java.awt.Paint)

Example 7 with AbstractGCEvent

use of com.tagtraum.perf.gcviewer.model.AbstractGCEvent in project GCViewer by chewiebug.

the class TestDataReaderSun1_2_2 method testParse1.

@Test
public void testParse1() throws Exception {
    AbstractGCEvent<GCEvent> event1 = new GCEvent(0, 817, 187, 819, 0.008, AbstractGCEvent.Type.GC);
    event1.getGeneration();
    AbstractGCEvent<GCEvent> event2 = new GCEvent(0.02, 775, 188, 819, 0.005, AbstractGCEvent.Type.GC);
    event2.getGeneration();
    AbstractGCEvent<GCEvent> event3 = new GCEvent(0.741, 1213, 1213, 1639, 0.0, AbstractGCEvent.Type.GC);
    event3.getGeneration();
    ByteArrayInputStream in = new ByteArrayInputStream(("<GC: 0 milliseconds since last GC>\n" + "<GC: freed 2807 objects, 645224 bytes in 8 ms, 77% free (646672/838856)>\n" + "  <GC: init&scan: 0 ms, scan handles: 7 ms, sweep: 1 ms, compact: 0 ms>\n" + "  <GC: 0 register-marked objects, 4 stack-marked objects>\n" + "  <GC: 1 register-marked handles, 42 stack-marked handles>\n" + "  <GC: refs: soft 0 (age >= 32), weak 0, final 2, phantom 0>\n" + "<GC: managing allocation failure: need 2128 bytes, type=1, action=1>\n" + "<GC: 20 milliseconds since last GC>\n" + "<GC: freed 672 objects, 601032 bytes in 5 ms, 77% free (646040/838856)>\n" + "<GC: 721 milliseconds since last GC>\n" + "<GC: expanded object space by 839680 to 1678536 bytes, 74% free>\n").getBytes());
    DataReader reader = new DataReaderSun1_2_2(new GcResourceFile("byteArray"), in);
    GCModel model = reader.read();
    assertEquals(3, model.size());
    Iterator<GCEvent> i = model.getGCEvents();
    GCEvent event = i.next();
    System.err.println(event.toString());
    assertEquals(event1, event);
    event = i.next();
    System.err.println(event.toString());
    assertEquals(event2, event);
    event = i.next();
    System.err.println(event.toString());
    assertEquals(event3, event);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) GCEvent(com.tagtraum.perf.gcviewer.model.GCEvent) AbstractGCEvent(com.tagtraum.perf.gcviewer.model.AbstractGCEvent) GcResourceFile(com.tagtraum.perf.gcviewer.model.GcResourceFile) GCModel(com.tagtraum.perf.gcviewer.model.GCModel) Test(org.junit.Test)

Example 8 with AbstractGCEvent

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();
}
Also used : AbstractGCEvent(com.tagtraum.perf.gcviewer.model.AbstractGCEvent) GCEvent(com.tagtraum.perf.gcviewer.model.GCEvent) AbstractGCEvent(com.tagtraum.perf.gcviewer.model.AbstractGCEvent)

Example 9 with AbstractGCEvent

use of com.tagtraum.perf.gcviewer.model.AbstractGCEvent in project GCViewer by chewiebug.

the class TestDataReaderSun1_3_1 method testParse1.

@Test
public void testParse1() throws Exception {
    AbstractGCEvent<GCEvent> event1 = new GCEvent(0, 8968, 8230, 10912, 0.0037192d, AbstractGCEvent.Type.GC);
    event1.getGeneration();
    AbstractGCEvent<GCEvent> event2 = new GCEvent(1, 8968, 8230, 10912, 0.0037192d, AbstractGCEvent.Type.GC);
    event2.getGeneration();
    AbstractGCEvent<GCEvent> event3 = new GCEvent(2, 8968, 8230, 10912, 0.0037192d, AbstractGCEvent.Type.GC);
    event3.getGeneration();
    AbstractGCEvent<GCEvent> event4 = new GCEvent(3, 10753, 6046, 10912, 0.3146707d, AbstractGCEvent.Type.FULL_GC);
    event4.getGeneration();
    ByteArrayInputStream in = new ByteArrayInputStream("[GC 8968K->8230K(10912K), 0.0037192 secs]\r\n[GC 8968K->8230K(10[GC 8968K->8230K(10912K), 0.0037192 secs]912K), 0.0037192 secs]\r\n[Full GC 10753K->6046K(10912K), 0.3146707 secs]".getBytes());
    DataReader reader = new DataReaderSun1_3_1(new GcResourceFile("byteArray"), in, GcLogType.SUN1_3_1);
    GCModel model = reader.read();
    assertTrue(model.size() == 4);
    Iterator<AbstractGCEvent<?>> i = model.getStopTheWorldEvents();
    AbstractGCEvent<?> event = i.next();
    assertEquals(event, event1);
    event = i.next();
    assertEquals(event, event2);
    event = i.next();
    assertEquals(event, event3);
    event = i.next();
    assertEquals(event, event4);
    assertEquals("throughput", 90.17011554119, model.getThroughput(), 0.00000001);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) AbstractGCEvent(com.tagtraum.perf.gcviewer.model.AbstractGCEvent) GCEvent(com.tagtraum.perf.gcviewer.model.GCEvent) AbstractGCEvent(com.tagtraum.perf.gcviewer.model.AbstractGCEvent) GcResourceFile(com.tagtraum.perf.gcviewer.model.GcResourceFile) GCModel(com.tagtraum.perf.gcviewer.model.GCModel) Test(org.junit.Test)

Example 10 with AbstractGCEvent

use of com.tagtraum.perf.gcviewer.model.AbstractGCEvent in project GCViewer by chewiebug.

the class DataReaderSun1_6_0 method parseLine.

protected AbstractGCEvent<?> parseLine(String line, ParseInformation pos) throws ParseException {
    AbstractGCEvent<?> ae = null;
    try {
        // parse datestamp          "yyyy-MM-dd'T'hh:mm:ssZ:"
        // parse timestamp          "double:"
        // parse collection type    "[TYPE"
        // either GC data or another collection type starting with timestamp
        // pre-used->post-used, total, time
        ZonedDateTime datestamp = parseDatestamp(line, pos);
        double timestamp = getTimestamp(line, pos, datestamp);
        ExtendedType type = parseType(line, pos);
        // special provision for CMS events
        if (type.getConcurrency() == Concurrency.CONCURRENT) {
            ae = new ConcurrentGCEvent();
            ConcurrentGCEvent event = (ConcurrentGCEvent) ae;
            // simple concurrent events (ending with -start) just are of type GcPattern.GC
            event.setDateStamp(datestamp);
            event.setTimestamp(timestamp);
            event.setExtendedType(type);
            if (type.getPattern() == GcPattern.GC_PAUSE_DURATION) {
                // the -end events contain a pause and duration as well
                int start = pos.getIndex();
                int end = line.indexOf('/', pos.getIndex());
                event.setPause(NumberParser.parseDouble(line.substring(start, end)));
                start = end + 1;
                end = line.indexOf(' ', start);
                event.setDuration(NumberParser.parseDouble(line.substring(start, end)));
            }
        // nothing more to parse...
        } else if (type.getCollectionType().equals(CollectionType.VM_OPERATION)) {
            ae = new VmOperationEvent();
            VmOperationEvent vmOpEvent = (VmOperationEvent) ae;
            vmOpEvent.setDateStamp(datestamp);
            vmOpEvent.setTimestamp(timestamp);
            vmOpEvent.setExtendedType(type);
            vmOpEvent.setPause(parsePause(line, pos));
        } else {
            ae = new GCEvent();
            GCEvent event = (GCEvent) ae;
            event.setDateStamp(datestamp);
            event.setTimestamp(timestamp);
            event.setExtendedType(type);
            // now add detail gcevents, should they exist
            parseDetailEventsIfExist(line, pos, event);
            if (event.getExtendedType().getPattern() == GcPattern.GC_MEMORY_PAUSE || event.getExtendedType().getPattern() == GcPattern.GC_MEMORY) {
                setMemory(event, line, pos);
            }
            // then more detail events follow (perm gen is usually here)
            parseDetailEventsIfExist(line, pos, event);
            if (event.getExtendedType().getPattern() == GcPattern.GC_MEMORY_PAUSE || event.getExtendedType().getPattern() == GcPattern.GC_PAUSE) {
                event.setPause(parsePause(line, pos));
            }
        }
        return ae;
    } catch (RuntimeException rte) {
        throw new ParseException("Error parsing entry (" + rte.toString() + ")", line, pos);
    }
}
Also used : ZonedDateTime(java.time.ZonedDateTime) AbstractGCEvent(com.tagtraum.perf.gcviewer.model.AbstractGCEvent)

Aggregations

AbstractGCEvent (com.tagtraum.perf.gcviewer.model.AbstractGCEvent)18 GCEvent (com.tagtraum.perf.gcviewer.model.GCEvent)13 GCModel (com.tagtraum.perf.gcviewer.model.GCModel)5 Paint (java.awt.Paint)3 GcResourceFile (com.tagtraum.perf.gcviewer.model.GcResourceFile)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 IOException (java.io.IOException)2 ZonedDateTime (java.time.ZonedDateTime)2 Test (org.junit.Test)2 VmOperationEvent (com.tagtraum.perf.gcviewer.model.VmOperationEvent)1 GradientPaint (java.awt.GradientPaint)1 Rectangle (java.awt.Rectangle)1 Locale (java.util.Locale)1 StringTokenizer (java.util.StringTokenizer)1