I started my emulator with ./emulator -trace profile -avd emulator_15. I then tracked down the trace files to ~/.android/avd/rodgers_emulator_15.avd/traces/profile, where there are six files: qtrace.bb, qtrace.exc, qtrace.insn, qtrace.method, qtrace.pid, qtrace.static. I can’t figure out what to do with these files. I’ve tried both dmtracedump and traceview on all of the files, but none seem to generate any output I can do anything with.
How can I view the proportion of time taken by native method calls on Android?
You need to use
tracedmdumpto convert the output. This is a shell function defined inbuild/envsetup.shin the full Android sources. If you’re using the SDK, rather than building from a full tree, I’m not sure this will work.(If you don’t have the sources and want to take a peek at the tracedmdump function, you can see it here.)
If you used
emulator -trace profile, you’d runtracedmdump profile. This will dig through various binaries to retrieve symbolic information and associate it with the trace data, generating an HTML summary and a traceview-compatible trace file.It’s worth noting that the VM will execute more slowly with profiling enabled (the interpreter has overhead on every method call and return, and it’s running in the slower “debug” interpreter), while native code continues to run at full speed, so you have to be careful when drawing conclusions.
General comment: don’t forget to use F9 or one of the method calls to start/stop the tracing — the
-traceflag just enables the feature.