奥门金沙糖果派对网站-金沙糖果派对手机版

Android培训课程-Creating Trace Files 建立跟踪文件

来源:四维梦工场    编辑:Anonymous    时间:2013/9/7    点击数:

  Creating Trace Files 建立跟踪文件

  To use Traceview, you need to generate log files containing the trace information you want to analyze. To do that, you include the Debug class in your code and call its methods to start and stop logging of trace information to disk. When your application quits, you can then use Traceview to examine the log files for useful run-time information such as method calls and run times.

  要使用Traceview进行分析,首先必须要生成你想要分析的跟踪信息日志文件。你可以这样生成跟踪信息日志文件,在你的代码中直接调用 Debug类的方法来记录跟踪信息并输出到日志文件中。当应用程序退出后,你就可以使用Traceview来对日志文件进行分析程序运行时的方法调用及运行次数等情况了。

  To create the trace files, include the Debug class and call one of the startMethodTracing() methods. In the call, you specify a base name for the trace files that the system generates. To stop tracing, call stopMethodTracing(). These methods start and stop method tracing across the entire virtual machine. For example, you could call startMethodTracing() in your activity's onCreate() method, and call stopMethodTracing() in that activity's onDestroy() method.

  为了生成跟踪日志文件,你应该在程序中包含Debug类并调用startMethodTracing()方法来开始进行日志跟踪,在这个调用方法中,你应该为跟踪日志文件指定一个名字。调用stopMethodTracing()方法来停止跟踪。这些方法可以在虚拟机上任意开始和停止方法跟踪。比如:你在activity's onCreate()方法中调用startMethodTracing()开始跟踪,并在activity's onDestroy()方法中调用stopMethodTracing()来结束跟踪。

  // start tracing to "/tmp/calc"

  Debug.startMethodTracing("/tmp/calc");

  // ...

  // stop tracing

  Debug.stopMethodTracing();

  When your application calls startMethodTracing(), the system creates two files:

  当你调用startMethodTracing(),系统会生成以下两个文件:

  <trace-base-name>.data -- contains binary method trace data

  <trace-base-name>.data --方法跟踪数据的二进制文件.

  <trace-base-name>.key -- a plain text file that contains mappings from binary identifiers to thread and method names

  <trace-base-name>.key --一个映射二进制文件中线程和方法名的纯文本文件.

  The system then begins buffering the generated trace data, until your application calls stopMethodTracing(), at which time it writes the buffered data to the files. If the system reaches the maximum buffer size before stopMethodTracing() is called, the system stops tracing and sends a notification to the console.

  跟踪开始后,系统对生成的跟踪数据是先进行缓存的,直到程序调用了stopMethodTracing()方法时才把缓存的数据写到文件中。如果在调用stopMethodTracing()前,系统已经达到了缓存最大值时,则系统就停止跟踪并发一个通知到控制台。

  The format of the trace files is described later in this document.

  跟踪文件的格式下面会详细进行说明.


XML 地图 | Sitemap 地图