Search in sources :

Example 1 with MassifSnapshot

use of org.eclipse.linuxtools.internal.valgrind.massif.MassifSnapshot in project linuxtools by eclipse.

the class BasicMassifTest method testNumSnapshots.

@Test
public void testNumSnapshots() throws Exception {
    ILaunchConfiguration config = createConfiguration(proj.getProject());
    // $NON-NLS-1$
    doLaunch(config, "testNumSnapshots");
    MassifViewPart view = (MassifViewPart) ValgrindUIPlugin.getDefault().getView().getDynamicView();
    MassifSnapshot[] snapshots = view.getSnapshots();
    assertEquals(14, snapshots.length);
    checkSnapshots(snapshots, 40, 16);
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) MassifSnapshot(org.eclipse.linuxtools.internal.valgrind.massif.MassifSnapshot) MassifViewPart(org.eclipse.linuxtools.internal.valgrind.massif.MassifViewPart) Test(org.junit.Test)

Example 2 with MassifSnapshot

use of org.eclipse.linuxtools.internal.valgrind.massif.MassifSnapshot in project linuxtools by eclipse.

the class MultiProcessTest method testExec.

@Test
public void testExec() throws CoreException, URISyntaxException, IOException {
    ILaunchConfigurationWorkingCopy config = createConfiguration(proj.getProject()).getWorkingCopy();
    config.setAttribute(LaunchConfigurationConstants.ATTR_GENERAL_TRACECHILD, true);
    config.doSave();
    // $NON-NLS-1$
    doLaunch(config, "testExec");
    MassifViewPart view = (MassifViewPart) ValgrindUIPlugin.getDefault().getView().getDynamicView();
    MassifOutput output = view.getOutput();
    Integer[] pids = output.getPids();
    assertEquals(2, pids.length);
    // child not necessarily higher PID than parent
    MassifSnapshot[] snapshots1 = output.getSnapshots(pids[0]);
    assertTrue(snapshots1.length == 8 || snapshots1.length == 14);
    MassifSnapshot[] snapshots2 = output.getSnapshots(pids[1]);
    assertTrue(snapshots2.length == 8 || snapshots2.length == 14);
    assertNotEquals(snapshots1.length, snapshots2.length);
    if (snapshots1.length == 8) {
        checkSnapshots(snapshots1, 400, 8);
        checkSnapshots(snapshots2, 40, 16);
    } else {
        checkSnapshots(snapshots1, 40, 16);
        checkSnapshots(snapshots2, 400, 8);
    }
}
Also used : MassifSnapshot(org.eclipse.linuxtools.internal.valgrind.massif.MassifSnapshot) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) MassifOutput(org.eclipse.linuxtools.internal.valgrind.massif.MassifOutput) MassifViewPart(org.eclipse.linuxtools.internal.valgrind.massif.MassifViewPart) Test(org.junit.Test)

Example 3 with MassifSnapshot

use of org.eclipse.linuxtools.internal.valgrind.massif.MassifSnapshot in project linuxtools by eclipse.

the class ChartEditor method createPartControl.

@Override
public void createPartControl(Composite parent) {
    final ChartEditorInput input = (ChartEditorInput) getEditorInput();
    final HeapChart heapChart = input.getChart();
    control = new Chart(parent, SWT.FILL);
    heapChart.setChartControl(control);
    final Color LIGHTYELLOW = new Color(Display.getDefault(), 255, 255, 225);
    final Color WHITE = Display.getDefault().getSystemColor(SWT.COLOR_WHITE);
    final Color BLACK = Display.getDefault().getSystemColor(SWT.COLOR_BLACK);
    final Color RED = Display.getDefault().getSystemColor(SWT.COLOR_RED);
    final Color ORANGE = new Color(Display.getDefault(), 255, 165, 0);
    final Color GREEN = Display.getDefault().getSystemColor(SWT.COLOR_GREEN);
    final Color DARK_BLUE = new Color(Display.getDefault(), 64, 128, 128);
    final int TICK_GAP = 40;
    control.setBackground(WHITE);
    control.setBackgroundInPlotArea(LIGHTYELLOW);
    FontData fd = JFaceResources.getDialogFont().getFontData()[0];
    fd.setStyle(SWT.BOLD);
    Font font = new Font(Display.getDefault(), fd);
    fd.setHeight(fd.getHeight() + 2);
    Font titleFont = new Font(Display.getDefault(), fd);
    ITitle title = control.getTitle();
    title.setFont(titleFont);
    title.setForeground(BLACK);
    title.setText(heapChart.title);
    IAxis xAxis = control.getAxisSet().getXAxis(0);
    xAxis.getGrid().setStyle(LineStyle.NONE);
    xAxis.getTick().setForeground(BLACK);
    ITitle xTitle = xAxis.getTitle();
    xTitle.setFont(font);
    xTitle.setForeground(BLACK);
    xTitle.setText(heapChart.xUnits);
    IAxis yAxis = control.getAxisSet().getYAxis(0);
    yAxis.getGrid().setStyle(LineStyle.SOLID);
    yAxis.getTick().setForeground(BLACK);
    yAxis.getTick().setTickMarkStepHint(TICK_GAP);
    ITitle yTitle = yAxis.getTitle();
    yTitle.setFont(font);
    yTitle.setText(heapChart.yUnits);
    yTitle.setForeground(BLACK);
    control.getLegend().setPosition(SWT.BOTTOM);
    // data
    final ILineSeries lsUseful = (ILineSeries) control.getSeriesSet().createSeries(SeriesType.LINE, // $NON-NLS-1$;
    Messages.getString("HeapChart.Useful_Heap"));
    lsUseful.setXSeries(heapChart.time);
    lsUseful.setYSeries(heapChart.dataUseful);
    lsUseful.setSymbolType(PlotSymbolType.DIAMOND);
    lsUseful.setSymbolColor(RED);
    lsUseful.setLineColor(RED);
    final ILineSeries lsExtra = (ILineSeries) control.getSeriesSet().createSeries(SeriesType.LINE, // $NON-NLS-1$;
    Messages.getString("HeapChart.Extra_Heap"));
    lsExtra.setXSeries(heapChart.time);
    lsExtra.setYSeries(heapChart.dataExtra);
    lsExtra.setSymbolType(PlotSymbolType.DIAMOND);
    lsExtra.setSymbolColor(ORANGE);
    lsExtra.setLineColor(ORANGE);
    if (heapChart.dataStacks != null) {
        final ILineSeries lsStack = (ILineSeries) control.getSeriesSet().createSeries(SeriesType.LINE, // $NON-NLS-1$;
        Messages.getString("HeapChart.Stacks"));
        lsStack.setXSeries(heapChart.time);
        lsStack.setYSeries(heapChart.dataStacks);
        lsStack.setSymbolType(PlotSymbolType.DIAMOND);
        lsStack.setSymbolColor(DARK_BLUE);
        lsStack.setLineColor(DARK_BLUE);
    }
    final ILineSeries lsTotal = (ILineSeries) control.getSeriesSet().createSeries(SeriesType.LINE, // $NON-NLS-1$;
    Messages.getString("HeapChart.Total_Heap"));
    lsTotal.setXSeries(heapChart.time);
    lsTotal.setYSeries(heapChart.dataTotal);
    lsTotal.setSymbolType(PlotSymbolType.DIAMOND);
    lsTotal.setSymbolColor(GREEN);
    lsTotal.setLineColor(GREEN);
    // adjust axes
    control.getAxisSet().adjustRange();
    IAxisSet axisSet = control.getAxisSet();
    Range xRange = axisSet.getXAxis(0).getRange();
    Range yRange = axisSet.getYAxis(0).getRange();
    double xExtra = 0.05 * (xRange.upper - xRange.lower);
    double yExtra = 0.05 * (yRange.upper - yRange.lower);
    axisSet.getXAxis(0).setRange(new Range(xRange.lower, xRange.upper + xExtra));
    axisSet.getYAxis(0).setRange(new Range(yRange.lower, yRange.upper + yExtra));
    // listeners
    control.getPlotArea().addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(MouseEvent e) {
            showView();
            TableViewer viewer = input.getView().getTableViewer();
            input.getView().setTopControl(viewer.getControl());
            Point p = new Point(e.x, e.y);
            int closest = 0;
            double d1, d2, d3, currMin;
            double globalMin = Double.MAX_VALUE;
            for (int i = 0; i < heapChart.time.length; i++) {
                // get distance from click event to data points for the given index
                d1 = distance(lsUseful.getPixelCoordinates(i), p);
                d2 = distance(lsExtra.getPixelCoordinates(i), p);
                d3 = distance(lsTotal.getPixelCoordinates(i), p);
                // find the closest data point to the click event
                currMin = Math.min(Math.min(d1, d2), d3);
                if (currMin < globalMin) {
                    closest = i;
                    globalMin = currMin;
                }
            }
            MassifSnapshot snapshot = (MassifSnapshot) viewer.getElementAt(closest);
            viewer.setSelection(new StructuredSelection(snapshot), true);
            if (e.count == 2 && snapshot.isDetailed()) {
                ChartLocationsDialog dialog = new ChartLocationsDialog(Display.getCurrent().getActiveShell());
                dialog.setInput(snapshot);
                if (dialog.open() == Window.OK) {
                    dialog.openEditorForResult();
                }
            }
        }
    });
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) Color(org.eclipse.swt.graphics.Color) FontData(org.eclipse.swt.graphics.FontData) ILineSeries(org.swtchart.ILineSeries) MouseAdapter(org.eclipse.swt.events.MouseAdapter) MassifSnapshot(org.eclipse.linuxtools.internal.valgrind.massif.MassifSnapshot) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) Point(org.eclipse.swt.graphics.Point) Range(org.swtchart.Range) ITitle(org.swtchart.ITitle) Point(org.eclipse.swt.graphics.Point) Font(org.eclipse.swt.graphics.Font) IAxis(org.swtchart.IAxis) IAxisSet(org.swtchart.IAxisSet) TableViewer(org.eclipse.jface.viewers.TableViewer) Chart(org.swtchart.Chart)

Example 4 with MassifSnapshot

use of org.eclipse.linuxtools.internal.valgrind.massif.MassifSnapshot in project linuxtools by eclipse.

the class AbstractMassifTest method checkSnapshots.

/**
 * Check snapshots contain the expected used bytes.
 *
 * @param snapshots MassifSnapshots to check
 * @param usefulBytesDelta scale of useful bytes
 * @param extraBytesDelta scale of extra bytes
 */
protected void checkSnapshots(MassifSnapshot[] snapshots, int usefulBytesDelta, int extraBytesDelta) {
    long expectedHeapBytes = 0;
    long expectedHeapExtraBytes = 0;
    boolean pastPeakUsage = false;
    for (MassifSnapshot snapshot : snapshots) {
        if (snapshot.getTime() == 0) {
        // no need to update expected values
        } else if (snapshot.getType().compareTo(SnapshotType.PEAK) == 0) {
            pastPeakUsage = true;
        // no need to update expected values
        } else if (!pastPeakUsage) {
            expectedHeapBytes += usefulBytesDelta;
            expectedHeapExtraBytes += extraBytesDelta;
        } else {
            // past the peak , heap bytes used begin to decrease
            expectedHeapBytes -= usefulBytesDelta;
            expectedHeapExtraBytes -= extraBytesDelta;
        }
        assertEquals(expectedHeapBytes, snapshot.getHeapBytes());
        assertEquals(expectedHeapExtraBytes, snapshot.getHeapExtra());
        assertEquals(expectedHeapBytes + expectedHeapExtraBytes, snapshot.getTotal());
    }
}
Also used : MassifSnapshot(org.eclipse.linuxtools.internal.valgrind.massif.MassifSnapshot)

Example 5 with MassifSnapshot

use of org.eclipse.linuxtools.internal.valgrind.massif.MassifSnapshot in project linuxtools by eclipse.

the class ChartTests method testChartLocationsDialog.

@Test
public void testChartLocationsDialog() throws Exception {
    ILaunchConfiguration config = createConfiguration(proj.getProject());
    // $NON-NLS-1$
    doLaunch(config, "testChartCallback");
    MassifViewPart view = (MassifViewPart) ValgrindUIPlugin.getDefault().getView().getDynamicView();
    // peak
    MassifSnapshot snapshot = view.getSnapshots()[7];
    assertTrue(snapshot.isDetailed());
    Shell parent = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    ChartLocationsDialog dialog = new ChartLocationsDialog(parent);
    dialog.setInput(snapshot);
    dialog.setBlockOnOpen(false);
    dialog.open();
    MassifHeapTreeNode element = snapshot.getRoot().getChildren()[1];
    dialog.getTableViewer().setSelection(new StructuredSelection(element));
    dialog.getOkButton().notifyListeners(SWT.Selection, null);
    dialog.openEditorForResult();
    checkFile(proj.getProject(), element);
    checkLine(element);
}
Also used : ChartLocationsDialog(org.eclipse.linuxtools.internal.valgrind.massif.charting.ChartLocationsDialog) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) Shell(org.eclipse.swt.widgets.Shell) MassifHeapTreeNode(org.eclipse.linuxtools.internal.valgrind.massif.MassifHeapTreeNode) MassifSnapshot(org.eclipse.linuxtools.internal.valgrind.massif.MassifSnapshot) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) MassifViewPart(org.eclipse.linuxtools.internal.valgrind.massif.MassifViewPart) Test(org.junit.Test)

Aggregations

MassifSnapshot (org.eclipse.linuxtools.internal.valgrind.massif.MassifSnapshot)9 MassifViewPart (org.eclipse.linuxtools.internal.valgrind.massif.MassifViewPart)6 Test (org.junit.Test)5 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)4 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 MassifHeapTreeNode (org.eclipse.linuxtools.internal.valgrind.massif.MassifHeapTreeNode)2 MassifOutput (org.eclipse.linuxtools.internal.valgrind.massif.MassifOutput)2 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)1 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 TreePath (org.eclipse.jface.viewers.TreePath)1 TreeSelection (org.eclipse.jface.viewers.TreeSelection)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 MassifTreeViewer (org.eclipse.linuxtools.internal.valgrind.massif.MassifTreeViewer)1 ChartLocationsDialog (org.eclipse.linuxtools.internal.valgrind.massif.charting.ChartLocationsDialog)1 MouseAdapter (org.eclipse.swt.events.MouseAdapter)1 MouseEvent (org.eclipse.swt.events.MouseEvent)1 Color (org.eclipse.swt.graphics.Color)1 Font (org.eclipse.swt.graphics.Font)1