use of org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindOutput in project linuxtools by eclipse.
the class CachegrindViewPart method getHeaderListener.
private SelectionListener getHeaderListener() {
return SelectionListener.widgetSelectedAdapter(e -> {
TreeColumn column = (TreeColumn) e.widget;
Tree tree = viewer.getTree();
if (column.equals(tree.getSortColumn())) {
int direction = tree.getSortDirection() == SWT.UP ? SWT.DOWN : SWT.UP;
tree.setSortDirection(direction);
} else {
tree.setSortDirection(SWT.UP);
}
tree.setSortColumn(column);
viewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
Tree tree = ((TreeViewer) viewer).getTree();
int direction = tree.getSortDirection();
ICachegrindElement o1 = (ICachegrindElement) e1;
ICachegrindElement o2 = (ICachegrindElement) e2;
long result = 0;
int sortIndex = Arrays.asList(tree.getColumns()).indexOf(tree.getSortColumn());
if (sortIndex == 0) {
// use compareTo
result = o1.compareTo(o2);
} else {
long[] v1 = null;
long[] v2 = null;
if (o1 instanceof CachegrindFunction && o2 instanceof CachegrindFunction) {
v1 = ((CachegrindFunction) o1).getTotals();
v2 = ((CachegrindFunction) o2).getTotals();
} else if (o1 instanceof CachegrindLine && o2 instanceof CachegrindLine) {
v1 = ((CachegrindLine) o1).getValues();
v2 = ((CachegrindLine) o2).getValues();
} else if (o1 instanceof CachegrindOutput && o2 instanceof CachegrindOutput) {
v1 = ((CachegrindOutput) o1).getSummary();
v2 = ((CachegrindOutput) o2).getSummary();
}
if (v1 != null && v2 != null) {
result = v1[sortIndex - 1] - v2[sortIndex - 1];
}
}
// ascending or descending
result = direction == SWT.UP ? result : -result;
// overflow check
if (result > Integer.MAX_VALUE) {
result = Integer.MAX_VALUE;
} else if (result < Integer.MIN_VALUE) {
result = Integer.MIN_VALUE;
}
return (int) result;
}
});
});
}
use of org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindOutput in project linuxtools by eclipse.
the class BasicCachegrindTest method testFileNames.
@Test
public void testFileNames() throws Exception {
ILaunchConfiguration config = createConfiguration(proj.getProject());
// $NON-NLS-1$
doLaunch(config, "testFileNames");
CachegrindViewPart view = (CachegrindViewPart) ValgrindUIPlugin.getDefault().getView().getDynamicView();
CachegrindOutput output = view.getOutputs()[0];
// $NON-NLS-1$
CachegrindFile file = getFileByName(output, "cpptest.cpp");
assertNotNull(file);
// $NON-NLS-1$
file = getFileByName(output, "cpptest.h");
assertNotNull(file);
}
use of org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindOutput in project linuxtools by eclipse.
the class BasicCachegrindTest method testNumFunctions.
@Test
public void testNumFunctions() throws Exception {
ILaunchConfiguration config = createConfiguration(proj.getProject());
// $NON-NLS-1$
doLaunch(config, "testNumFunctions");
CachegrindViewPart view = (CachegrindViewPart) ValgrindUIPlugin.getDefault().getView().getDynamicView();
CachegrindOutput output = view.getOutputs()[0];
// $NON-NLS-1$
CachegrindFile file = getFileByName(output, "cpptest.cpp");
assertNotNull(file);
assertEquals(8, file.getFunctions().length);
}
use of org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindOutput in project linuxtools by eclipse.
the class CModelLabelsTest method testMethodLabel.
@Test
public void testMethodLabel() throws Exception {
ILaunchConfiguration config = createConfiguration(proj.getProject());
// $NON-NLS-1$
doLaunch(config, "testMethodLabel");
CachegrindViewPart view = (CachegrindViewPart) ValgrindUIPlugin.getDefault().getView().getDynamicView();
CachegrindOutput output = view.getOutputs()[0];
// $NON-NLS-1$
CachegrindFile file = getFileByName(output, "cpptest.cpp");
// $NON-NLS-1$
CachegrindFunction func = getFunctionByName(file, "A::A()");
assertTrue(func.getModel() instanceof IMethod);
checkLabelProvider(func, file);
}
use of org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindOutput in project linuxtools by eclipse.
the class CModelLabelsTest method testFileLabelsCPP.
@Test
public void testFileLabelsCPP() throws Exception {
ILaunchConfiguration config = createConfiguration(proj.getProject());
// $NON-NLS-1$
doLaunch(config, "testFileLabelsCPP");
CachegrindViewPart view = (CachegrindViewPart) ValgrindUIPlugin.getDefault().getView().getDynamicView();
CachegrindOutput output = view.getOutputs()[0];
// $NON-NLS-1$
CachegrindFile file = getFileByName(output, "cpptest.cpp");
assertTrue(file.getModel() instanceof ITranslationUnit);
checkLabelProvider(file);
}
Aggregations