在应用程序代码android中使用systrace

时间:2021-09-09 00:24:05

The documentation in android says

android中的文档说

you can use the methods of the Trace class to add instrumentation to 
your application code and see the results in a Systrace report.

I have added the below methods to my code

我在代码中添加了以下方法

Trace.beginSection("test-trace");  

// block of code

Trace.endSection();

Now where can I check the results of this section. I start the systrace tool from the android device monitor and recorded it for 30 secs(performed the button click that executes the above the block). It generates the trace.html file but how do i get the above section information from this html file

现在我在哪里可以查看本节的结果。我从android设备监视器启动systrace工具并将其记录30秒(执行按钮单击执行上面的块)。它生成trace.html文件,但如何从此html文件中获取上述部分信息

3 个解决方案

#1


It is there, I myself searched for it about one hour :D

它在那里,我自己搜索了大约一个小时:D

If you have only one thread, it's shown in UI thread row, otherwise it's shown in your-defined thread row.

如果您只有一个线程,则显示在UI线程行中,否则它将显示在您定义的线程行中。

If you can not find it, use the search toolbox, in top right corner of page, type 'test-trace' there and it will show you the start time of that in detail

如果找不到,请使用页面右上角的搜索工具箱,在那里键入“test-trace”,它会详细显示其开始时间

:)

this screenshot may help you

这个截图可能对你有帮助

#2


The systrace output only includes the tags that are listed on the command line. For app-specific tracing, that means adding a --app=package-name argument. This is necessary because systrace logs the entire system, and you wouldn't want it to automatically pick up the traces for every app and component.

systrace输出仅包括命令行中列出的标记。对于特定于应用程序的跟踪,这意味着添加--app = package-name参数。这是必要的,因为systrace会记录整个系统,您不希望它自动为每个应用程序和组件选取跟踪。

You can find an example here. For a program with package name com.faddensoft.multicoretest, you would use a command line like:

你可以在这里找到一个例子。对于包名为com.faddensoft.multicoretest的程序,您可以使用如下命令行:

python systrace.py --app=com.faddensoft.multicoretest gfx view sched dalvik

With that, your tracing should appear in the row of the thread that's issuing the trace calls. (Open the HTML file in a web browser; might need to use Chrome.)

这样,您的跟踪应该出现在发出跟踪调用的线程的行中。 (在Web浏览器中打开HTML文件;可能需要使用Chrome。)

#3


Probably you recorded too long, make sure to increase buffer size with -b command, or simply follow this example:

可能你记录的时间太长,请确保使用-b命令增加缓冲区大小,或者只是按照以下示例:

python systrace.py  -app=package_name sched freq idle am wm gfx view dalvik input binder_driver -t 30 -o test.html -b 30384

#1


It is there, I myself searched for it about one hour :D

它在那里,我自己搜索了大约一个小时:D

If you have only one thread, it's shown in UI thread row, otherwise it's shown in your-defined thread row.

如果您只有一个线程,则显示在UI线程行中,否则它将显示在您定义的线程行中。

If you can not find it, use the search toolbox, in top right corner of page, type 'test-trace' there and it will show you the start time of that in detail

如果找不到,请使用页面右上角的搜索工具箱,在那里键入“test-trace”,它会详细显示其开始时间

:)

this screenshot may help you

这个截图可能对你有帮助

#2


The systrace output only includes the tags that are listed on the command line. For app-specific tracing, that means adding a --app=package-name argument. This is necessary because systrace logs the entire system, and you wouldn't want it to automatically pick up the traces for every app and component.

systrace输出仅包括命令行中列出的标记。对于特定于应用程序的跟踪,这意味着添加--app = package-name参数。这是必要的,因为systrace会记录整个系统,您不希望它自动为每个应用程序和组件选取跟踪。

You can find an example here. For a program with package name com.faddensoft.multicoretest, you would use a command line like:

你可以在这里找到一个例子。对于包名为com.faddensoft.multicoretest的程序,您可以使用如下命令行:

python systrace.py --app=com.faddensoft.multicoretest gfx view sched dalvik

With that, your tracing should appear in the row of the thread that's issuing the trace calls. (Open the HTML file in a web browser; might need to use Chrome.)

这样,您的跟踪应该出现在发出跟踪调用的线程的行中。 (在Web浏览器中打开HTML文件;可能需要使用Chrome。)

#3


Probably you recorded too long, make sure to increase buffer size with -b command, or simply follow this example:

可能你记录的时间太长,请确保使用-b命令增加缓冲区大小,或者只是按照以下示例:

python systrace.py  -app=package_name sched freq idle am wm gfx view dalvik input binder_driver -t 30 -o test.html -b 30384