• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Viewing HiTraceMeter Logs
2
3## Viewing Logs on DevEco Studio
4
5In CPU Insight of DevEco Studio Profiler, you can display HiTraceMeter logs for analyzing the CPU usage and thread running status of applications and services and viewing the CPU consumption in a specified period. For details, see [CPU Activity Analysis: CPU](https://developer.huawei.com/consumer/en/doc/harmonyos-guides-V5/ide-insight-session-cpu-V5).
6
7## Viewing Logs Using a Command Line Tool
8
91. Set up the environment for OpenHarmony Device Connector (hdc). For details, see [Environment Setup](hdc.md#environment-setup).
10
112. In the **Terminal** window of DevEco Studio or the CLI on the host, run the **hdc shell** command to connect to the device, and run the [hitrace](hitrace.md) command on the device to capture HiTraceMeter logs.
12
13   ```shell
14   PS D:\xxx\xxx> hdc shell
15   # hitrace --trace_begin app
16   ```
17
183. Run the program that enables HiTraceMeter logging on the device.
19
204. Dump the HiTraceMeter log file that contains the HiTraceMeter logging information in step 3.
21
22   - Logs are printed in the window by default.
23
24   ```shell
25   # hitrace --trace_dump
26   ```
27
28   - You can create a file to save logs in the **/data/local/tmp/** directory (other directories are unavailable).
29
30   ```shell
31   # hitrace --trace_dump -o /data/local/tmp/trace.ftrace
32   ```
33
345. Run the **hitrace** command on the device to stop capturing HiTraceMeter logs.
35
36   ```shell
37   # hitrace --trace_finish
38   ```
39
406. Exit the device, enter the host, and export the HiTraceMeter logs to the current directory.
41
42   ```shell
43   # exit
44   PS D:\xxx\xxx> hdc file recv /data/local/tmp/trace.ftrace ./
45   ```
46
477. You can search for keywords such as the logging name in the HiTraceMeter logs to check whether the logging is successful.
48
498. Display and analyze the HiTraceMeter logs.
50
51   - In DevEco Studio Profiler, select **Open File** to import the HiTraceMeter logs for analysis. For details, see [CPU Activity Analysis: CPU](https://developer.huawei.com/consumer/en/doc/harmonyos-guides-V5/ide-insight-session-cpu-V5).
52   - Use [HiSmartPerf](https://gitee.com/openharmony/developtools_smartperf_host) for analysis. You can download the tool from [developertools_smartperf_host Release](https://gitee.com/openharmony/developtools_smartperf_host/releases).
53