• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Introduction to HiTraceMeter
2
3<!--Kit: Performance Analysis Kit-->
4<!--Subsystem: HiviewDFX-->
5<!--Owner: @qq_437963121-->
6<!--SE: @MontSaintMichel-->
7<!--TSE: @gcw_KuLfPSbe-->
8
9This topic describes how to use the HitraceMeter APIs. You can call them to log traces, and then use [HiTrace](hitrace.md) to obtain the trace information generated during program running. In this way, you can learn about the program running process, thread, timestamp, and CPU information for performance profiling and optimization.
10
11
12HitraceMeter provides ArkTs and C/C++ APIs. You can select the APIs as required.
13
14
15- [Using HiTraceMeter (ArkTS)](hitracemeter-guidelines-arkts.md)
16
17- [Using HiTraceMeter (C/C++)](hitracemeter-guidelines-ndk.md)
18
19
20## Implementation Principles
21
22The kernel sets a buffer to record the logs generated during device running and provides the **trace_marker** and **trace** nodes in sysfs.
23
24The **trace_marker** node is write-only. After the program writes the logging information to this node, the information is stored in the kernel buffer. The (ArkTS and C++) HiTraceMeter APIs encapsulate the write operation on this node. Applications can call these APIs to write the logging data to the kernel node.
25
26The **trace** node is read-only, from which all trace records in the current buffer of the system can be read. HiTrace encapsulates the read operation on this node. You can run commands to display the collected logging information to the CLI or save the information to a file on the device side.
27
28For the format of logging information generated by calling the HitraceMeter API, see [User-Mode Trace Format](hitracemeter-view.md#user-mode-trace-format).
29
30**HiTraceMeter Tag**: type of the trace data. Generally, each software subsystem corresponds to a tag. You can call **hitrace -l** in the hdc CLI to view all tag names and their introductions. When using [HiTrace](hitrace.md) to collect trace data, you need to specify a tag. The collection result contains only the trace data of the specified tag. To call HiTraceMeter in an application, use the **app** tag.
31