use of com.android.tools.adtui.chart.hchart.MethodUsage in project android by JetBrains.
the class AppTrace method generateStats.
private void generateStats(HNode<MethodUsage> usageNode, long totalDuration) {
long childTotalRuntime = 0;
for (HNode<MethodUsage> childExecNode : usageNode.getChildren()) {
childTotalRuntime += childExecNode.getData().getInclusiveDuration();
}
long exlusiveDuration = usageNode.getData().getInclusiveDuration() - childTotalRuntime;
usageNode.getData().setExclusiveDuration(exlusiveDuration);
usageNode.getData().setExclusivePercentage(exlusiveDuration / (float) totalDuration);
if (childTotalRuntime == 0) {
// This is a leaf. Recursion stops here.
return;
}
long cursor = usageNode.getStart();
for (HNode<MethodUsage> childUsageNode : usageNode.getChildren()) {
MethodUsage methodUsage = childUsageNode.getData();
childUsageNode.setStart(cursor);
cursor += methodUsage.getInclusiveDuration();
childUsageNode.setEnd(cursor);
methodUsage.setInclusivePercentage(childUsageNode.duration() / (float) totalDuration);
}
// Recurse over all childs
for (HNode<MethodUsage> child : usageNode.getChildren()) {
generateStats(child, totalDuration);
}
}
Aggregations