Search in sources :

Example 1 with VmOperationEvent

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

the class ModelMetricsPanelTest method testVmOpModel.

@Test
public void testVmOpModel() {
    GCEvent event = new GCEvent();
    event.setTimestamp(0.5);
    event.setType(Type.G1_YOUNG_INITIAL_MARK);
    event.setPause(0.245);
    event.setPreUsed(900);
    event.setPostUsed(400);
    event.setTotal(1024);
    GCModel model = new GCModel();
    model.add(event);
    VmOperationEvent vmOpEvent = new VmOperationEvent();
    vmOpEvent.setTimestamp(0.7);
    vmOpEvent.setType(Type.APPLICATION_STOPPED_TIME);
    vmOpEvent.setPause(0.26);
    model.add(vmOpEvent);
    ModelMetricsPanel panel = new ModelMetricsPanel();
    // first add empty model; is done when opened
    panel.setModel(new GCModel());
    // only later a model with entries is set
    panel.setModel(model);
}
Also used : VmOperationEvent(com.tagtraum.perf.gcviewer.model.VmOperationEvent) GCEvent(com.tagtraum.perf.gcviewer.model.GCEvent) GCModel(com.tagtraum.perf.gcviewer.model.GCModel) Test(org.junit.Test)

Example 2 with VmOperationEvent

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

the class GCRectanglesRenderer method paintComponent.

public void paintComponent(Graphics2D g2d) {
    // make sure that we ignore the AntiAliasing flag as it does not make sense for vertical lines
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
    final double scaleFactor = getModelChart().getScaleFactor();
    final double scaledHeight = (getHeight() / getModelChart().getMaxPause());
    int lastWidth = Integer.MIN_VALUE;
    int lastHeight = Integer.MIN_VALUE;
    int lastX = Integer.MIN_VALUE;
    int lastY = Integer.MIN_VALUE;
    Rectangle clip = g2d.getClipBounds();
    int leftBoundary = clip.x;
    int rightBoundary = clip.x + clip.width;
    for (Iterator<AbstractGCEvent<?>> i = getModelChart().getModel().getStopTheWorldEvents(); i.hasNext() && lastX < rightBoundary; ) {
        AbstractGCEvent<?> event = i.next();
        double pause = event.getPause();
        int width = (int) Math.max(Math.abs(scaleFactor * pause), 1.0d);
        int height = (int) (pause * scaledHeight);
        int x = (int) (scaleFactor * (event.getTimestamp() - getModelChart().getModel().getFirstPauseTimeStamp()));
        int y = getHeight() - (int) (pause * scaledHeight);
        if (lastX != x || lastY != y || lastWidth != width || lastHeight != height) {
            if ((x + width) > leftBoundary && x < rightBoundary) {
                // make sure only visible rectangles are drawn
                if (event.isFull()) {
                    g2d.setPaint(Color.BLACK);
                } else if (event.isInitialMark()) {
                    g2d.setPaint(Color.BLUE);
                } else if (event.isRemark()) {
                    g2d.setPaint(Color.ORANGE);
                } else if (event.getExtendedType().getType() == AbstractGCEvent.Type.INC_GC) {
                    g2d.setPaint(brighter);
                } else if (event instanceof VmOperationEvent) {
                    g2d.setPaint(Color.RED);
                } else {
                    g2d.setPaint(getLinePaint());
                }
                g2d.fillRect(x, y, width, height);
            }
            lastWidth = width;
            lastHeight = height;
            lastX = x;
            lastY = y;
        }
    }
}
Also used : VmOperationEvent(com.tagtraum.perf.gcviewer.model.VmOperationEvent) Rectangle(java.awt.Rectangle) AbstractGCEvent(com.tagtraum.perf.gcviewer.model.AbstractGCEvent) Paint(java.awt.Paint)

Aggregations

VmOperationEvent (com.tagtraum.perf.gcviewer.model.VmOperationEvent)2 AbstractGCEvent (com.tagtraum.perf.gcviewer.model.AbstractGCEvent)1 GCEvent (com.tagtraum.perf.gcviewer.model.GCEvent)1 GCModel (com.tagtraum.perf.gcviewer.model.GCModel)1 Paint (java.awt.Paint)1 Rectangle (java.awt.Rectangle)1 Test (org.junit.Test)1