Systrace on Android 4.3

2019-05-13 22:48发布

问题:

I'm trying to measure performance attributes of my app through systrace by using the new Trace API introduced in JB 4.3. The idea is similar to the use of traceview method profiling, i.e. you can measure a specific code section using Trace.beginSection and Trace.endSection.

However, when I run systrace through the python script provided in Android tools, I don't see anything relating to the sections specified by the above calls.

Am I missing something? Is this the correct way of accessing the systrace output? I see in the documentation for the Trace calls that it "Writes trace events to the system trace buffer", but I have no idea how to access the trace buffer.

Any help appreciated.

回答1:

You have to provide an additional argument to the systrace command: -app=pkgname (or -a pkgname) where, pkgname is the package name from your app manifest. It's also the name you see in the ps output (which is possibly more relevant, since that's what it's matching against).

There is an example here.