• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file
18 * @kit ArkUI
19 */
20
21/**
22 * Provides interfaces to monitor a scene for performance measurement.
23 *
24 * <p>These interfaces are used to monitor the begin, end, and value changes of finger processes that last for at least 3 ms.
25 *
26 * <p>Example:
27 * import "@ohos.arkui.performanceMonitor.d.ts"
28 * To start scene monitoring that is expected to complete within 5 ms:
29 * <pre>{@code
30 * performanceMonitor.begin(string, ActionType, string);
31 * //scene finished
32 * performanceMonitor.end(string);
33 * }</pre>
34 *
35 * <p>Each {@code begin} matches one {@code end}, and they must have the same scene id.
36 *
37 * @namespace performanceMonitor
38 * @syscap SystemCapability.ArkUI.ArkUI.Full
39 * @systemapi
40 * @since 10
41 */
42declare namespace performanceMonitor {
43  /**
44   * Enumerates the input event type.
45   *
46   * @enum { number }
47   * @syscap SystemCapability.ArkUI.ArkUI.Full
48   * @systemapi
49   * @since 10
50   */
51  export enum ActionType {
52    /**
53     * The user presses the finger on the screen.
54     * @syscap SystemCapability.ArkUI.ArkUI.Full
55     * @systemapi
56     * @since 10
57     */
58    LAST_DOWN = 0,
59
60    /**
61     * The user lifts up the finger from the screen.
62     * @syscap SystemCapability.ArkUI.ArkUI.Full
63     * @systemapi
64     * @since 10
65     */
66    LAST_UP = 1,
67
68    /**
69     * The user first moves the finger after pressing down the screen.
70     * @syscap SystemCapability.ArkUI.ArkUI.Full
71     * @systemapi
72     * @since 10
73     */
74    FIRST_MOVE = 2
75  }
76
77  /**
78   * Enumerates the input source type.
79   *
80   * @enum { number }
81   * @syscap SystemCapability.ArkUI.ArkUI.Full
82   * @systemapi
83   * @since 12
84   */
85  export enum SourceType {
86    /**
87     * The user touches the screen to trigger the scene.
88     * @syscap SystemCapability.ArkUI.ArkUI.Full
89     * @systemapi
90     * @since 12
91     */
92    PERF_TOUCH_EVENT = 0,
93
94    /**
95     * TThe user uses the mouse to trigger the scene.
96     * @syscap SystemCapability.ArkUI.ArkUI.Full
97     * @systemapi
98     * @since 12
99     */
100    PERF_MOUSE_EVENT = 1,
101
102    /**
103     * The user uses the touchpad to trigger the scene.
104     * @syscap SystemCapability.ArkUI.ArkUI.Full
105     * @systemapi
106     * @since 12
107     */
108    PERF_TOUCHPAD_EVENT = 2,
109
110    /**
111     * The user uses the joystick to trigger the scene.
112     * @syscap SystemCapability.ArkUI.ArkUI.Full
113     * @systemapi
114     * @since 12
115     */
116    PERF_JOYSTICK_EVENT = 3,
117
118    /**
119     * The user uses the keyboard to trigger the scene.
120     * @syscap SystemCapability.ArkUI.ArkUI.Full
121     * @systemapi
122     * @since 12
123     */
124    PERF_KEY_EVENT = 4
125  }
126
127  /**
128   * Begin monitoring an application scene.
129   *
130   * @param { string } scene Indicates the scene name.
131   * @param { ActionType } startInputType Indicates the scene input event type.
132   * @param { string } note Indicates the app expected info delivered.
133   * @syscap SystemCapability.ArkUI.ArkUI.Full
134   * @systemapi
135   * @since 10
136   */
137  function begin(scene: string, startInputType: ActionType, note?: string): void;
138
139  /**
140   * End monitoring an application scene.
141   *
142   * @param { string } scene Indicates the scene name. It must be the same with the {@code scene} of start.
143   * @syscap SystemCapability.ArkUI.ArkUI.Full
144   * @systemapi
145   * @since 10
146   */
147  function end(scene: string): void;
148
149  /**
150   * recordInputEventTime monitoring an application scene.
151   *
152   * @param { ActionType } type - Indicates the scene input event type.
153   * @param { SourceType } sourceType - Indicates the scene input source type.
154   * @param { number } time - Indicates the scene input time.
155   * @throws { BusinessError } 202 - not system application.
156   * @syscap SystemCapability.ArkUI.ArkUI.Full
157   * @systemapi
158   * @since 12
159   */
160  function recordInputEventTime(type: ActionType, sourceType: SourceType, time: number): void;
161}
162export default performanceMonitor;
163