perfetto icon indicating copy to clipboard operation
perfetto copied to clipboard

What is the method to obtain the duration of different states in slice?

Open ChenJiahao-A opened this issue 2 years ago • 1 comments

Slice binder transaction Details Name binder transaction Category binder Start time 00:00:03.217450385 Absolute Time 2024-04-03T03:51:49.011813574

Duration
91ms 552us 692ns
Sleeping
75ms 387us 154ns (82.34%)
Runnable
16ms 142us 462ns (17.63%)
Running
23us 76ns (0.03%)

ChenJiahao-A avatar Apr 08 '24 08:04 ChenJiahao-A

This join should give you what you want. It also uses function that might not yet be available in sched.time_in_state module, so you might have to run it directly from https://cs.android.com/android/platform/superproject/main/+/main:external/perfetto/src/trace_processor/perfetto_sql/stdlib/sched/time_in_state.sql

You can also make it a PERFETTO FUNCTION that takes id as an argument.

INCLUDE PERFETTO MODULE sched.time_in_state;
INCLUDE PERFETTO MODULE slices.with_context;

SELECT s.*
FROM sched_time_in_state_for_thread_in_interval(t.ts, t.dur, t.utid) s 
JOIN thread_slice t WHERE id = 3;

aMayzner avatar Apr 08 '24 09:04 aMayzner