For perf-timer async support (Trio), I implemented the smallest possible thing: within a task, measure time excluding periods where the task is de-scheduled (sleeping, blocked on i/o or an event, etc.)
However, there is a strong use case for including the time spent in descendant tasks of the instrumented task (spawned by a nursery). This aggregate time would directly correlate to CPU usage. For example, if you measured the duration of async function foo() including child tasks as 5 s, while the total application runtime was 100 s, that means foo() was responsible for 5% of the CPU use.
For perf-timer async support (Trio), I implemented the smallest possible thing: within a task, measure time excluding periods where the task is de-scheduled (sleeping, blocked on i/o or an event, etc.)
However, there is a strong use case for including the time spent in descendant tasks of the instrumented task (spawned by a nursery). This aggregate time would directly correlate to CPU usage. For example, if you measured the duration of async function
foo()including child tasks as 5 s, while the total application runtime was 100 s, that meansfoo()was responsible for 5% of the CPU use.