Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
6f98dfa3
D
Docs
项目概览
OpenHarmony
/
Docs
大约 1 年 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6f98dfa3
编写于
6月 13, 2023
作者:
C
chenwei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
hitraceMeter Native接口样例添加
Signed-off-by:
N
chenwei
<
chenwei469@huawei.com
>
上级
c0137d3f
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
22 addition
and
22 deletion
+22
-22
zh-cn/application-dev/dfx/hitracemeter-native-guidelines.md
zh-cn/application-dev/dfx/hitracemeter-native-guidelines.md
+22
-22
未找到文件。
zh-cn/application-dev/dfx/hitracemeter-native-guidelines.md
浏览文件 @
6f98dfa3
...
...
@@ -2,7 +2,9 @@
## 概述
hiTraceMeter为开发者提供系统性能打点接口。开发者通过在自己的业务逻辑中的关键代码位置调用HiTraceMeter接口提供的API接口,能够有效跟踪进程轨迹、查看系统性能。
> **说明:**
> 仅当开发者使用Native API开发应用时,可参考本开发指导。JS文档请参考[HitraceMeter JS API参考](../reference/apis/js-apis-hitracemeter.md)。API文档请参考[HitraceMeter API参考](./hitracemeter-guidelines.md)。
>
> - 仅当开发者使用Native API开发应用时,可参考本开发指导。
> - 如需使用ArkTS API开发应用,请参考对应的[开发指导](hitracemeter-guidelines.md)和[API参考](../reference/apis/js-apis-hitracemeter.md)。
## 接口说明
| 方法 | 接口描述 |
| -------- | -------- |
...
...
@@ -11,34 +13,32 @@ hiTraceMeter为开发者提供系统性能打点接口。开发者通过在自
| void OH_HiTrace_StartAsyncTrace(const char
*
name, int32_t taskId) | 开启一个异步时间片跟踪事件 |
| void OH_HiTrace_FinishAsyncTrace(const char
*
name, int32_t taskId) | 结束一个异步时间片跟踪事件 |
| void OH_HiTrace_CountTrace(const char
*
name, int64_t count) | 整数跟踪事件 |
## 参数解析
**参数解析:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| name | string | 否 | 要跟踪的数值变量名称。 |
| taskId | number | 否 | 用来表示关联的ID,如果有多个name相同的任务是并行执行的,则每次调用startTrace的taskId不同。 |
| count | number | 否 | 变量的值。 |
## 开发示例
1.
在CMakeLists.txt中新增libhitrace_ndk.z.so链接
:
1.
在CMakeLists.txt中新增libhitrace_ndk.z.so链接
。
```
target_link_libraries(entry PUBLIC libhitrace_ndk.z.so)
target_link_libraries(entry PUBLIC libhitrace_ndk.z.so)
```
2.
在源文件中
包含hitrace头文件:
2.
在源文件中
引用hitrace头文件。
```
c++
#include "hitrace/trace.h"
#include "hitrace/trace.h"
```
3.
打开hdc shell,使能trace
3.
打开hdc shell,使能trace
,命令是:hitrace --trace_begin app。
```
shell
# hitrace --trace_begin app
capturing trace...
capturing trace...
```
4.
进行性能打点,以异步打点为例
:
4.
进行性能打点,以异步打点为例
。
```
c++
OH_HiTrace_StartAsyncTrace
(
"hitraceTest"
,
123
);
OH_HiTrace_FinishAsyncTrace
(
"hitraceTest"
,
123
);
OH_HiTrace_StartAsyncTrace
(
"hitraceTest"
,
123
);
OH_HiTrace_FinishAsyncTrace
(
"hitraceTest"
,
123
);
```
5.
dump trace查看结果
:
5.
dump trace查看结果
,命令是:hitrace --trace_dump | grep hitraceTest。
```
shell
# hitrace --trace_dump | grep hitraceTest
<...>-2477
(
-------
)
[
001] .... 396.427165: tracing_mark_write: S|2477|H:hitraceTest 123
<...>-2477
(
-------
)
[
001] .... 396.427196: tracing_mark_write: F|2477|H:hitraceTest 123
```
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录