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 arkts {'1.1':'10','1.2':'20'} 41 * @arkts 1.1&1.2 42 */ 43declare namespace performanceMonitor { 44 /** 45 * Enumerates the input event type. 46 * 47 * @enum { number } 48 * @syscap SystemCapability.ArkUI.ArkUI.Full 49 * @systemapi 50 * @since arkts {'1.1':'10','1.2':'20'} 51 * @arkts 1.1&1.2 52 */ 53 export enum ActionType { 54 /** 55 * The user presses the finger on the screen. 56 * @syscap SystemCapability.ArkUI.ArkUI.Full 57 * @systemapi 58 * @since arkts {'1.1':'10','1.2':'20'} 59 * @arkts 1.1&1.2 60 */ 61 LAST_DOWN = 0, 62 63 /** 64 * The user lifts up the finger from the screen. 65 * @syscap SystemCapability.ArkUI.ArkUI.Full 66 * @systemapi 67 * @since arkts {'1.1':'10','1.2':'20'} 68 * @arkts 1.1&1.2 69 */ 70 LAST_UP = 1, 71 72 /** 73 * The user first moves the finger after pressing down the screen. 74 * @syscap SystemCapability.ArkUI.ArkUI.Full 75 * @systemapi 76 * @since arkts {'1.1':'10','1.2':'20'} 77 * @arkts 1.1&1.2 78 */ 79 FIRST_MOVE = 2 80 } 81 82 /** 83 * Enumerates the input source type. 84 * 85 * @enum { number } 86 * @syscap SystemCapability.ArkUI.ArkUI.Full 87 * @systemapi 88 * @since arkts {'1.1':'12','1.2':'20'} 89 * @arkts 1.1&1.2 90 */ 91 export enum SourceType { 92 /** 93 * The user touches the screen to trigger the scene. 94 * @syscap SystemCapability.ArkUI.ArkUI.Full 95 * @systemapi 96 * @since arkts {'1.1':'12','1.2':'20'} 97 * @arkts 1.1&1.2 98 */ 99 PERF_TOUCH_EVENT = 0, 100 101 /** 102 * TThe user uses the mouse to trigger the scene. 103 * @syscap SystemCapability.ArkUI.ArkUI.Full 104 * @systemapi 105 * @since arkts {'1.1':'12','1.2':'20'} 106 * @arkts 1.1&1.2 107 */ 108 PERF_MOUSE_EVENT = 1, 109 110 /** 111 * The user uses the touchpad to trigger the scene. 112 * @syscap SystemCapability.ArkUI.ArkUI.Full 113 * @systemapi 114 * @since arkts {'1.1':'12','1.2':'20'} 115 * @arkts 1.1&1.2 116 */ 117 PERF_TOUCHPAD_EVENT = 2, 118 119 /** 120 * The user uses the joystick to trigger the scene. 121 * @syscap SystemCapability.ArkUI.ArkUI.Full 122 * @systemapi 123 * @since arkts {'1.1':'12','1.2':'20'} 124 * @arkts 1.1&1.2 125 */ 126 PERF_JOYSTICK_EVENT = 3, 127 128 /** 129 * The user uses the keyboard to trigger the scene. 130 * @syscap SystemCapability.ArkUI.ArkUI.Full 131 * @systemapi 132 * @since arkts {'1.1':'12','1.2':'20'} 133 * @arkts 1.1&1.2 134 */ 135 PERF_KEY_EVENT = 4 136 } 137 138 /** 139 * Begin monitoring an application scene. 140 * 141 * @param { string } scene Indicates the scene name. 142 * @param { ActionType } startInputType Indicates the scene input event type. 143 * @param { string } note Indicates the app expected info delivered. 144 * @syscap SystemCapability.ArkUI.ArkUI.Full 145 * @systemapi 146 * @since arkts {'1.1':'10','1.2':'20'} 147 * @arkts 1.1&1.2 148 */ 149 function begin(scene: string, startInputType: ActionType, note?: string): void; 150 151 /** 152 * End monitoring an application scene. 153 * 154 * @param { string } scene Indicates the scene name. It must be the same with the {@code scene} of start. 155 * @syscap SystemCapability.ArkUI.ArkUI.Full 156 * @systemapi 157 * @since arkts {'1.1':'10','1.2':'20'} 158 * @arkts 1.1&1.2 159 */ 160 function end(scene: string): void; 161 162 /** 163 * recordInputEventTime monitoring an application scene. 164 * 165 * @param { ActionType } type - Indicates the scene input event type. 166 * @param { SourceType } sourceType - Indicates the scene input source type. 167 * @param { number } time - Indicates the scene input time. 168 * @throws { BusinessError } 202 - not system application. 169 * @syscap SystemCapability.ArkUI.ArkUI.Full 170 * @systemapi 171 * @since arkts {'1.1':'12','1.2':'20'} 172 * @arkts 1.1&1.2 173 */ 174 function recordInputEventTime(type: ActionType, sourceType: SourceType, time: number): void; 175} 176export default performanceMonitor; 177