js-apis-arkui-performancemonitor.md 1.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
# @ohos.arkui.performanceMonitor  (性能监测)

用户操作场景提供性能相关指标监测能力,目前仅包含响应时延、完成时延、丢帧。

> **说明:**
>
> 从API Version 10开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
>
> 本模块接口为系统接口。


## 导入模块

```ts
L
l00613276 已提交
15
import performanceMonitor from '@ohos.arkui.performanceMonitor';
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
```


## ActionType

用户场景触发模式枚举。

**系统能力:** SystemCapability.ArkUI.ArkUI.Full

| 名称 | 值 | 说明 |
| -- | -- | -- |
| LAST_DOWN | 0 | 用户按压事件触发。  |
| LAST_UP | 1 | 用户离手事件触发。 |
| FIRST_MOVE | 2 | 用户首次滑动事件触发。 |


## performanceMonitor.begin

begin(scene: string, startInputType: ActionType, note?: string): void

用户场景开始。


**系统能力:** SystemCapability.ArkUI.ArkUI.Full

**参数:** 
L
l00613276 已提交
42

43 44
| 参数名 | 类型 | 必填 | 说明 |
| -- | -- | -- | -- |
L
l00613276 已提交
45 46 47
| scene | string | 是 | 用户场景id。 |
| startInputType | [ActionType](#actiontype)| 是 | 用户场景触发模式。 |
| note | string| 否 | 用户场景重要信息。 |
48 49 50 51 52 53 54 55 56

**示例:** 
  ```ts
performanceMonitor.begin("LAUNCHER_APP_LAUNCH_FROM_ICON", performanceMonitor.ActionType.LAST_UP, "APP_START_BEGIN");
  ```


## performanceMonitor.end

L
l00613276 已提交
57
end(scene: string): void
58 59 60 61 62 63 64 65

用户场景结束

**系统能力:** SystemCapability.ArkUI.ArkUI.Full

**参数:** 
| 参数名 | 类型 | 必填 | 说明 |
| -- | -- | -- | -- |
L
l00613276 已提交
66
| scene | string | 是 | 用户场景id,与begin配对。 |
67 68 69 70 71

**示例:** 
  ```ts
performanceMonitor.end("LAUNCHER_APP_LAUNCH_FROM_ICON");
  ```