如何查看Android原生代码分析?
我使用 ./emulator -trace profile -avd emulator_15 启动了模拟器。然后我将跟踪文件跟踪到 ~/.android/avd/rodgers_emulator_15.avd/traces/profile,其中有六个文件:qtrace.bb、qtrace.exc、qtrace.insn、qtrace.method、qtrace.pid、qtrace 。静止的。我不知道如何处理这些文件。我已经在所有文件上尝试了 dmtracedump 和traceview,但似乎都没有生成我可以做任何事情的输出。
Android上如何查看native方法调用所花费的时间比例?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要使用
tracedmdump
来转换输出。这是完整 Android 源代码中build/envsetup.sh
中定义的 shell 函数。如果您使用 SDK,而不是从完整的树构建,我不确定这是否可行。(如果您没有源代码并且想查看tracedmdump函数,您可以查看它此处。)
如果您使用
emulator -trace profile
,您将运行tracedmdump 配置文件
。这将挖掘各种二进制文件以检索符号信息并将其与跟踪数据关联,从而生成 HTML 摘要和与 Traceview 兼容的跟踪文件。值得注意的是,启用分析后,VM 的执行速度会更慢(解释器在每个方法调用和返回上都有开销,并且它在较慢的“调试”解释器中运行),而本机代码继续全速运行,因此您有下结论时要小心。
一般评论:不要忘记使用 F9 或其中一个方法调用来启动/停止跟踪 -
-trace
标志只是启用该功能。You need to use
tracedmdump
to convert the output. This is a shell function defined inbuild/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 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
-trace
flag just enables the feature.为了使用这六个文件,与 dmtracedump 相同的目录中还有其他脚本,例如 read_pid、read_trace、profile_trace 等。您应该首先在包含这六个文件的跟踪目录上运行 post_trace,然后您可以使用以下任何一个它们获取配置文件信息,例如每个基本块的执行频率、它们所属的 pid 等。
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.