use of org.talend.designer.runtime.visualization.internal.core.cpu.IMethodNode in project tdi-studio-se by Talend.
the class AbstractFilteredTree method updateStatusLine.
/**
* Updates the status line.
*
* @param selection the selection
*/
public void updateStatusLine(IStructuredSelection selection) {
IStatusLineManager manager = actionBars.getStatusLineManager();
IContributionItem[] items = manager.getItems();
StatusLineContributionItem selfTimeStatusLineItem = null;
for (IContributionItem item : items) {
if (item instanceof StatusLineContributionItem) {
selfTimeStatusLineItem = (StatusLineContributionItem) item;
}
}
// create the status line
if (selfTimeStatusLineItem == null) {
//$NON-NLS-1$
selfTimeStatusLineItem = new StatusLineContributionItem("SelfTimeContributionItem");
manager.add(selfTimeStatusLineItem);
}
// clear the status line
if (selection == null) {
selfTimeStatusLineItem.setText(Util.ZERO_LENGTH_STRING);
return;
}
// set text on status line
double percentage = 0;
double time = 0;
for (Object object : selection.toArray()) {
if (object instanceof IMethodNode) {
percentage += ((IMethodNode) object).getSelfTimeInPercentage();
time += ((IMethodNode) object).getSelfTime();
}
}
String text = Util.ZERO_LENGTH_STRING;
if (percentage != 0) {
//$NON-NLS-1$
text = String.format("Self Time: %.0fms %.1f", time, percentage) + '%';
}
selfTimeStatusLineItem.setText(text);
}
use of org.talend.designer.runtime.visualization.internal.core.cpu.IMethodNode in project tdi-studio-se by Talend.
the class HotSpotsLabelProvider method getSelfTimeInMsColumnText.
/**
* Gets the self time in milliseconds column text.
*
* @param element the element
* @return the self time column text
*/
private String getSelfTimeInMsColumnText(Object element) {
ICpuModel cpuModel = (ICpuModel) filteredTree.getViewer().getInput();
if (cpuModel == null) {
//$NON-NLS-1$
return "";
}
if (element instanceof IMethodNode) {
long selfTime = ((IMethodNode) element).getSelfTime();
int length = String.valueOf(cpuModel.getMaxSelfTime() * 1000).length();
length = (length > 10) ? 10 : length;
return getMillisecondsText(selfTime, length);
}
//$NON-NLS-1$
return "";
}
use of org.talend.designer.runtime.visualization.internal.core.cpu.IMethodNode in project tdi-studio-se by Talend.
the class ShowCallersCalleesAction method selectionChanged.
/*
* @see ISelectionChangedListener#selectionChanged(SelectionChangedEvent)
*/
@Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
if (!(selection instanceof StructuredSelection)) {
return;
}
Object element = ((StructuredSelection) selection).getFirstElement();
if (element instanceof IMethodNode) {
callesCalleesTargetNode = (IMethodNode) element;
setEnabled(true);
} else {
setEnabled(false);
}
}
use of org.talend.designer.runtime.visualization.internal.core.cpu.IMethodNode in project tdi-studio-se by Talend.
the class CallerCalleeTabPage method refreshContentDescription.
/**
* Refreshes the content description.
*/
private void refreshContentDescription() {
if (jvm == null) {
return;
}
StringBuilder description = new StringBuilder();
IMethodNode callersCalleesTarget = jvm.getCpuProfiler().getCpuModel().getCallersCalleesTarget();
if (callersCalleesTarget != null) {
description.append(NLS.bind(Messages.callersCalleesTargetIndicator, callersCalleesTarget.getName()));
}
ICpuModel cpuModel = jvm.getCpuProfiler().getCpuModel();
ICallTreeNode focusedNode = cpuModel.getFocusTarget();
if (focusedNode != null) {
if (callersCalleesTarget != null) {
description.append(NLS.bind(Messages.focusTargetIndicator, focusedNode.getNonqualifiedName()));
}
}
String thread = null;
if (focusedNode != null) {
thread = focusedNode.getThread();
} else if (callersCalleesTarget != null) {
thread = callersCalleesTarget.getThread();
}
if (description.length() > 0 && thread != null) {
description.append(NLS.bind(Messages.threadIndicator, thread));
}
setContentDescription(description.toString());
}
use of org.talend.designer.runtime.visualization.internal.core.cpu.IMethodNode in project tdi-studio-se by Talend.
the class HotSpotsComparator method compare.
/*
* @see ViewerComparator#compare(Viewer, Object, Object)
*/
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
int result = 0;
if (!(e1 instanceof IMethodNode) || !(e2 instanceof IMethodNode)) {
return result;
}
IMethodNode method1 = (IMethodNode) e1;
IMethodNode method2 = (IMethodNode) e2;
if (columnType == ColumnType.Methods) {
result = method1.getName().compareTo(method2.getName());
} else if (columnType == ColumnType.TimeMs) {
result = (method1.getSelfTime() > method2.getSelfTime()) ? 1 : -1;
} else if (columnType == ColumnType.TimePercentage) {
result = (method1.getSelfTimeInPercentage() > method2.getSelfTimeInPercentage()) ? 1 : -1;
} else if (columnType == ColumnType.Count) {
result = (method1.getInvocationCount() > method2.getInvocationCount()) ? 1 : -1;
}
if (sortDirection == SWT.DOWN) {
result *= -1;
}
return result;
}
Aggregations