Status Update
Comments
ra...@google.com <ra...@google.com> #2
ja...@gmail.com <ja...@gmail.com> #3
Hi. Apologies for wading in; can one add "CPU Usage" (ie as per what Studio displays when opening a perfetto file) using TraceMetric
?
I should add that it seems like I should be using PerfettoTraceProcessor
and loading the generated trace files (say, in an @After
function), but thought I'd check!
cc...@google.com <cc...@google.com> #4
Yes, anything that shows up when studio or ui.perfetto.dev loads a Perfetto trace can be queried with TraceMetric, though you may have to do some digging through the perfetto trace processor documentation to find out how:
Generally suggest opening up
To get you started for CPU usage, you can do something like:
select cmdline as process_name, SUM(dur) / 1000000.0 as dur_ms from sched
inner join thread USING(utid)
inner join process USING(upid)
group by upid
order by dur_ms desc
Which gives a descending order list of CPU usage times, in milliseconds, for each process in the UI. You can instead use "WHERE" clauses to limit the data to just the processes you care about.
ja...@gmail.com <ja...@gmail.com> #5
Thanks! Very helpful.
dv...@gmail.com <dv...@gmail.com> #6
Yes, I have already use TraceMetric to extend Mertics. However, the configure/start/stop of TraceMetric is internal, I can't override to custmoize behavior.
Let me explain what I am facing.
I am working in Phone device maker, I am trying to use Macrobenchmark out of Android Studio to write CUJ(Critical User Journey) macrobenchmark test.
I have write a APP with instrumentation label in AndroidManifest.xml, and import macrobenchmark library to it.
by that way, I can use macrobenchmark out of Android Studio.
I want to measure CUJs by collecting metrics.
for whats user care about, I want to collect startup metric(the startup type, latency), touch metric(touch latency), frame metric(how many frames are over 64ms threshold, how many deadline time a frames skips, how many jank frames in total frames), memory metric(how many memory does it uses)
for what system developers care about, I want to collect cpu stats(how many runnable, running, uninterrupting sleeping time), memory stats(page fault...), io stats(write back, read in, gc ...), lock contentions, long binder calling.
Giving a example, I am using macrobenchmark try to find memory leaks in Tiktok CUJ on the device.
I need write a memory sampling metric, starting sampling when metric is configured, get callbacks when memory bumps or over the memory threshold. to screenshot and dumpheap.
I want to init this metric in configure(package:String) function, however this functoin is internal, I can't overide it.
beyond that, I need start/stop simpleperf during each iteration, so that I can figure out which cause memory leaks.
So, I need a metric which I can override configure, start, stop. TraceMetric I can only overide getResult, That's not enought.
BTW, I find I can't override PerfettoConfig, macrobenchmark use PerfettoConfig.benchmark as default, sometimes I need add datasource which is unique to device makers.
It wastes time to write the macrobenchmark again, can you make it more customizable?
cc...@google.com <cc...@google.com>
cc...@google.com <cc...@google.com> #7
Thanks for the specifics, that's very useful. These are all valid requests - we'll look at opening up this in 1.3
dv...@gmail.com <dv...@gmail.com> #8
Thank you very much ~
Description
Component used: androidx.benchmark.macro Version used: latest Devices/Android versions reproduced on: Pixel 6
If this is a bug in the library, we would appreciate if you could attach:
Sealed androidx.benchmark.macro.Metric class prevents me to extend Metrics.
I need extend metrics, however the Metric class is sealed, I can't extend it.
can you remove the sealed keyword on Metric class, and internal keyword on the functions in Metric class?