use of com.android.tools.profilers.cpu.ThreadStateDataSeries in project android by JetBrains.
the class ThreadsSegment method initializeStateChartsList.
private void initializeStateChartsList() {
mThreadsList.setCellRenderer(new ThreadsStateCellRenderer());
mThreadsList.setSelectionBackground(AdtUiUtils.DEFAULT_BACKGROUND_COLOR);
mThreadsList.setFixedCellHeight(mCellHeight);
if (mThreadSelectedListener != null) {
mThreadsList.addListSelectionListener((event) -> {
int[] selectedThreadsIndices = mThreadsList.getSelectedIndices();
List<ThreadStateDataSeries> selectedThreads = new ArrayList<>();
for (int i = 0; i < selectedThreadsIndices.length; i++) {
selectedThreads.add(mThreadsListModel.get(selectedThreadsIndices[i]));
}
mThreadSelectedListener.onSelected(selectedThreads);
});
}
mThreadsList.addMouseMotionListener(new MouseAdapter() {
@Override
public void mouseMoved(MouseEvent me) {
Point p = new Point(me.getX(), me.getY());
int index = mThreadsList.locationToIndex(p);
if (index != mHoveredListIndex) {
mHoveredListIndex = index;
mThreadsList.repaint();
}
}
});
}
use of com.android.tools.profilers.cpu.ThreadStateDataSeries in project android by JetBrains.
the class CpuProfilerUiManager method onSelected.
@Override
public void onSelected(@NotNull List<ThreadStateDataSeries> selectedThreads) {
// TODO: Only support mono-selection for now:
if (selectedThreads.size() != 1) {
return;
}
myEventDispatcher.getMulticaster().profilerExpanded(ProfilerType.CPU);
resetDetailedComponents();
ThreadStateDataSeries selectedThread = selectedThreads.get(0);
int threadId = selectedThread.getProcessId();
AppTrace trace = TraceDataStore.getInstance().getLastThreadsActivity(myProject.getName());
if (trace == null) {
// No trace have been generated.
return;
}
SparseArray<HNode<Method>> availableThreads = trace.getThreadsGraph();
if (availableThreads.get(threadId) == null) {
return;
}
// Setup topdown panel
SparseArray<JComponent> topDownTrees = trace.getTopDownTrees();
myTopdownJpanel.add(topDownTrees.get(threadId), BorderLayout.CENTER);
// Setup bottomup panel
SparseArray<JComponent> bottomUpTrees = trace.getBottomUpTrees();
myBottomupJPanel.add(bottomUpTrees.get(threadId), BorderLayout.CENTER);
// Setup execution panel
HNode<Method> executionTree = availableThreads.get(threadId);
myExecutionChart.setHTree(executionTree);
if (AppTrace.Source.ART == trace.getSource()) {
myExecutionChart.setHRenderer(new NativeMethodHRenderer());
} else {
myExecutionChart.setHRenderer(new JavaMethodHRenderer());
}
// Setup flame graph
SparseArray<HNode<MethodUsage>> usageTrees = trace.getTopdownStats();
HNode<MethodUsage> usageTree = usageTrees.get(threadId);
myFlameChart.setHTree(usageTree);
myFlameChartRange.set(usageTree.getStart(), usageTree.getEnd());
myFlameChart.setXRange(myFlameChartRange);
if (AppTrace.Source.ART == trace.getSource()) {
myFlameChart.setHRenderer(new NativeMethodUsageHRenderer());
} else {
myFlameChart.setHRenderer(new JavaMethodUsageHRenderer());
}
// TODO: Selection doesn't seem right. Fix it and also set the proper color (red highlight).
// TODO: Reinvestigate sycning selection with the LineChart
myTimeSelectionRangeUs.set(executionTree.getStart(), executionTree.getEnd());
//myTimeSelectionRangeUs.lockValues();
// Setup view with a little bit of margin so selection can be seen.
//long duration = executionTree.getEnd() - executionTree.getStart();
//long durationMargin = duration / 10;
//myTimeCurrentRangeUs.set(executionTree.getStart() - durationMargin, executionTree.getEnd() + durationMargin);
//myTimeCurrentRangeUs.lockValues();
}
Aggregations