Viewing HiTraceMeter Logs
Note:
Currently in the beta phase.
Viewing via DevEco Studio Visual Interface
Developers can use the CPU Insight feature in DevEco Studio Profiler to visually display HiTraceMeter log content, analyze the CPU usage and thread running status of applications/services, and examine the execution time consumption of programs on the CPU during specified time periods. For detailed usage instructions, refer to CPU Activity Analysis: CPU Profiling.
Viewing via Command Line Tools
-
Follow the hdc command-line tool guide to complete Environment Preparation, ensuring the
hdc shellcommand can properly connect to the device. -
Execute the
hdc shellcommand in DevEco Studio's Terminal window or the host command-line window to connect to the device. Then, run the hitrace command on the device to start the HiTraceMeter log capture service.PS D:\xxx\xxx> hdc shell # hitrace --trace_begin app -
Run the program containing HiTraceMeter instrumentation points on the device.
-
Dump the HiTraceMeter text logs, which include the HiTraceMeter instrumentation information from step 3.
- By default, logs are printed in the window.
# hitrace --trace_dump- Alternatively, provide a filename to save the logs to a file. The file path must be
/data/local/tmp/, as other paths lack permissions.
# hitrace --trace_dump -o /data/local/tmp/trace.ftrace -
Execute the hitrace command on the device to stop the HiTraceMeter log capture service.
# hitrace --trace_finish -
Exit the device, return to the host, and export the HiTraceMeter text logs from the device to the current directory.
# exit PS D:\xxx\xxx> hdc file recv /data/local/tmp/trace.ftrace ./ -
Search for keywords such as instrumentation names in the HiTraceMeter text logs to verify successful instrumentation.
-
Visual analysis of HiTraceMeter text logs.
- Import into DevEco Studio for analysis. Refer to the CPU Activity Analysis: CPU Profiling documentation. In DevEco Studio Profiler's session area, select "Open File" to import the HiTraceMeter text logs for analysis.
- Use Smartperf_Host for analysis. You can download the tool from developtools_smartperf_host Release.