hiTraceMeter provides APIs for system performance tracing. You can call the APIs provided by the hiTraceMeter module in your own service logic to effectively track service processes and check the system performance.
> **NOTE**
> - This development guide is applicable only when you use Native APIs for application development. For details about APIs, see [API Reference](../reference/native-apis/_hitrace.md).
> - For details about how to use ArkTS APIs for application development, see [Development Guidelines](hitracemeter-guidelines.md) and [API Reference](../reference/apis/js-apis-hitracemeter.md).
## Available APIs
| API| Description|
| -------- | -------- |
| void OH_HiTrace_StartTrace(const char* name) | Starts a synchronous time slice trace.|
| void OH_HiTrace_FinishTrace() | Ends a synchronous time slice trace.|
| void OH_HiTrace_StartAsyncTrace(const char* name, int32_t taskId) | Starts an asynchronous time slice trace.|
| void OH_HiTrace_FinishAsyncTrace(const char* name, int32_t taskId) | Ends an asynchronous time slice trace.|
| taskId | number | No | ID used to indicate the association of APIs in a trace. If multiple traces with the same name need to be performed at the same time or a trace needs to be performed multiple times concurrently, different task IDs must be specified in **startTrace**.|
| count | number | No | Value of the variable. |
## Development Example
1. Add the link of **libhitrace_ndk.z.so** to **CMakeLists.txt**.
```
target_link_libraries(entry PUBLIC libhitrace_ndk.z.so)
```
2. Reference the **hitrace** header file in the source file.
```c++
#include "hitrace/trace.h"
```
3. Open the hdc shell and run the **hitrace --trace_begin app** command to enable the trace function.
```shell
capturing trace...
```
4. Perform a performance trace. The following uses asynchronous trace as an example.
```c++
OH_HiTrace_StartAsyncTrace("hitraceTest",123);
OH_HiTrace_FinishAsyncTrace("hitraceTest",123);
```
5. Run the **hitrace --trace_dump | grep hitraceTest** command to view the trace result.
@@ -26,7 +26,7 @@ For details about the requirements on the Linux environment, see [Quick Start](.
The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568) as an example to illustrate thermal log customization.
1. Create the `thermal` folder in the product directory [/vendor/hihope/rk3568](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568).
1. Create the thermal folder in the product directory [/vendor/hihope/rk3568](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568).
2. Create a target folder by referring to the [default thermal log configuration folder](https://gitee.com/openharmony/drivers_peripheral/tree/master/thermal/interfaces/hdi_service/profile), and install it in `//vendor/hihope/rk3568/thermal`. The content is as follows:
...
...
@@ -50,8 +50,6 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma
| Configuration Item| Description| Data Type| Value Range|
| -------- | -------- | -------- | -------- |
| interval | Interval for recording temperature tracing logs, in ms.| int | >0 |
| width | Width of the temperature tracing log, in characters.| int | >0 |
| outpath | Path for storing temperature tracing logs.| string | N/A|
**Table 2** Description of the node configuration
...
...
@@ -63,7 +61,7 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma
| value | path | Path for obtaining the thermal zone temperature.|
6. Write the `BUILD.gn` file by referring to the [BUILD.gn](https://gitee.com/openharmony/drivers_peripheral/blob/master/thermal/interfaces/hdi_service/profile/BUILD.gn) file in the default thermal log configuration folder to pack the `thermal_hdi_config.xml` file to the `//vendor/etc/thermal_config/hdf` directory. The configuration is as follows:
6. Write the `BUILD.gn` file by referring to the [BUILD.gn](https://gitee.com/openharmony/drivers_peripheral/blob/master/thermal/interfaces/hdi_service/profile/BUILD.gn) file in the default thermal log configuration folder to pack the thermal_hdi_config.xml file to the `//vendor/etc/thermal_config/hdf` directory. The configuration is as follows:
```shell
import("//build/ohos.gni")
...
...
@@ -97,7 +95,7 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma
ohos_prebuilt_etc("thermal_hdf_config") {
source = "thermal_hdi_config.xml"
relative_install_dir = "thermal_config/hdf"
install_images = [ chipset_base_dir ] # Required configuration for installing the thermal_hdi_config.xml file in the vendor directory.
install_images = [ chipset_base_dir ] # Required configuration for installing the thermal_service_config.xml file in the vendor directory.
part_name = "product_rk3568" # Set part_name to product_rk3568 for subsequent build. You can change it as required.
}
```
...
...
@@ -151,7 +149,7 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma
"subsystem": "product_hihope"
}
```
In the preceding code, `//vendor/hihope/rk3568/thermal/` is the folder path, `profile` and `etc` are folder names, and `thermal_hdf_config` and `param_files` are the build targets.
In the preceding code, //vendor/hihope/rk3568/thermal/ is the folder path, profile and etc are folder names, and thermal_hdf_config and param_files are the build targets.
9. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md).