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