1# bytrace<a name="EN-US_TOPIC_0000001083359811"></a> 2 3## Overview<a name="section11388623181619"></a> 4 5bytrace is a tool for you to trace processes and analyze performance. It encapsulates and extends the kernel ftrace and supports event tracking in the user space. With bytrace, you can open a user-space or kernel-space label you want to view \(run the **bytrace -l** command to query all the supported labels\) and run the **--trace\_begin** and **-o filename** \(or **--output filename**\) commands to capture traces and dump them to a specified file. 6 7## How to Develop<a name="section1595564317164"></a> 8 9bytrace supports the following commands: 10 11**Table 1** Commands 12 13| Option | Description | 14| -------- | -------- | 15| -h, --help | Views the help text for bytrace. | 16| -b _n_, --buffer_size _n_ | Sets the size of the buffer (KB) for storing and reading traces. The default buffer size is 2048 KB. | 17| -t _n_, --time _n_ | Sets the bytrace uptime in seconds, which depends on the time required for analysis. | 18| --trace_clock _clock_ | Sets the type of the clock for adding a timestamp to a trace, which can be **boot** (default), **global**, **mono**, **uptime**, or **perf**. | 19| --trace_begin | Starts capturing traces. | 20| --trace_dump | Dumps traces to a specified position (console where you run this command by default). | 21| --trace_finish | Stops capturing traces and dumps traces to a specified position (console where you run this command by default). | 22| -l, --list_categories | Lists the bytrace categories supported by the device. | 23| --overwrite | Sets the action to take when the buffer is full. If this option is used, the latest traces are discarded; if this option is not used, the earliest traces are discarded (default). | 24| -o _filename_, --output _filename_ | Outputs traces to a specified file. | 25| -z | Compresses a captured trace. | 26 27## Usage Example<a name="section667273201818"></a> 28 29The following are some examples of bytrace commands: 30 31- Query supported labels. 32 33``` 34bytrace -l 35``` 36 37Alternatively, run the following command to query the supported bytrace categories: 38 39``` 40bytrace --list_categories 41``` 42 43- Capture traces whose label is ability, with the buffer size set to 4096 KB and bytrace uptime set to 10s. 44 45``` 46bytrace -b 4096 -t 10 --overwrite ability > /data/mytrace.ftrace 47``` 48 49- Set the clock type for traces to **mono**. 50 51``` 52bytrace --trace_clock mono -b 4096 -t 10 --overwrite ability > /data/mytrace.ftrace 53``` 54 55- Compress the captured trace. 56 57``` 58bytrace -z -b 4096 -t 10 --overwrite ability > /data/mytrace.ftrace 59``` 60 61