Android systrace 中的 Self Time 代表什么?

What does Self Time stand for in Android systrace?

在 android 系统跟踪中选择任何切片时,我看到了自我时间值。自我时间是什么意思?

对于自底向上树顶部的方法或函数(顶部节点)

Represents the total time the method or function spent executing its own code and not that of its callees. Compared to the top down tree, this timing information represents a sum of all calls to this method or function over the duration of the recording.

来电者 (sub-nodes)

Represents the total self time of the callee when being called by the caller. Using the bottom up tree in figure 9 as an example, the self time for method B would equal the sum of the self times for each execution of method C when called by B.

其他资源:https://developer.android.com/studio/profile/cpu-profiler

除了 myselfmiqdad 的回答之外,您还可以查看来自 Android Dev Summit '19 的演讲:https://youtu.be/v4kCRZ_O4Lc,其中介绍了自我时间、children 时间和详细总时间。

至于 systrace,虽然它显示的是跟踪事件而不是调用堆栈,但它们被组织在类似于调用堆栈的树中。所以自我时间的概念仍然适用:self_time = total_time - sum(children_total_time)