开发者

How to View Android Native Code Profiling?

开发者 https://www.devze.com 2022-12-24 07:34 出处:网络
I started my emulator with ./emula开发者_如何学JAVAtor -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

I started my emulator with ./emula开发者_如何学JAVAtor -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 tracedmdump to convert the output. This is a shell function defined in build/envsetup.sh in 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 run tracedmdump 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 -trace flag just enables the feature.


In order to use those six files, there are other scripts in the same directory as that of dmtracedump such as read_pid, read_trace, profile_trace etc. U should first run post_trace on the trace directory containing the six files, then you can use any one of them to get profile info such as how often each basic block executes, the pids they belong to etc.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号