Search in sources :

Example 6 with MethodUsage

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);
    }
}
Also used : MethodUsage(com.android.tools.adtui.chart.hchart.MethodUsage)

Aggregations

MethodUsage (com.android.tools.adtui.chart.hchart.MethodUsage)6 HNode (com.android.tools.adtui.model.HNode)4 Method (com.android.tools.adtui.chart.hchart.Method)1 AppStatTreeNode (com.android.tools.idea.monitor.ui.cpu.view.AppStatTreeNode)1 Stack (java.util.Stack)1