Viewing HiTraceMeter Logs
Viewing Logs on DevEco Studio
In 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.
Viewing Logs Using a Command Line Tool
-
Set up the environment for OpenHarmony Device Connector (hdc). For details, see Environment Setup.
-
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 command on the device to capture HiTraceMeter logs.
PS D:\xxx\xxx> hdc shell # hitrace --trace_begin app -
Run the program that enables HiTraceMeter logging on the device.
-
Dump the HiTraceMeter log file that contains the HiTraceMeter logging information in step 3.
- Logs are printed in the window by default.
# hitrace --trace_dump- You can create a file to save logs in the /data/local/tmp/ directory (other directories are unavailable).
# hitrace --trace_dump -o /data/local/tmp/trace.ftrace -
Run the hitrace command on the device to stop capturing HiTraceMeter logs.
# hitrace --trace_finish -
Exit the device, enter the host, and export the HiTraceMeter logs to the current directory.
# exit PS D:\xxx\xxx> hdc file recv /data/local/tmp/trace.ftrace ./ -
You can search for keywords such as the logging name in the HiTraceMeter logs to check whether the logging is successful.
-
Display and analyze the HiTraceMeter logs.
- In DevEco Studio Profiler, select Open File to import the HiTraceMeter logs for analysis. For details, see CPU Activity Analysis: CPU.
- Use HiSmartPerf for analysis. You can download the tool from developertools_smartperf_host Release.