161847f8eSopenharmony_ci/* 261847f8eSopenharmony_ci * Copyright (C) 2023 Huawei Device Co., Ltd. 361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 461847f8eSopenharmony_ci * you may not use this file except in compliance with the License. 561847f8eSopenharmony_ci * You may obtain a copy of the License at 661847f8eSopenharmony_ci * 761847f8eSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 861847f8eSopenharmony_ci * 961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and 1361847f8eSopenharmony_ci * limitations under the License. 1461847f8eSopenharmony_ci */ 1561847f8eSopenharmony_ci 1661847f8eSopenharmony_ci/** 1761847f8eSopenharmony_ci * @file 1861847f8eSopenharmony_ci * @kit ArkUI 1961847f8eSopenharmony_ci */ 2061847f8eSopenharmony_ci 2161847f8eSopenharmony_ci/** 2261847f8eSopenharmony_ci * Provides interfaces to monitor a scene for performance measurement. 2361847f8eSopenharmony_ci * 2461847f8eSopenharmony_ci * <p>These interfaces are used to monitor the begin, end, and value changes of finger processes that last for at least 3 ms. 2561847f8eSopenharmony_ci * 2661847f8eSopenharmony_ci * <p>Example: 2761847f8eSopenharmony_ci * import "@ohos.arkui.performanceMonitor.d.ts" 2861847f8eSopenharmony_ci * To start scene monitoring that is expected to complete within 5 ms: 2961847f8eSopenharmony_ci * <pre>{@code 3061847f8eSopenharmony_ci * performanceMonitor.begin(string, ActionType, string); 3161847f8eSopenharmony_ci * //scene finished 3261847f8eSopenharmony_ci * performanceMonitor.end(string); 3361847f8eSopenharmony_ci * }</pre> 3461847f8eSopenharmony_ci * 3561847f8eSopenharmony_ci * <p>Each {@code begin} matches one {@code end}, and they must have the same scene id. 3661847f8eSopenharmony_ci * 3761847f8eSopenharmony_ci * @namespace performanceMonitor 3861847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 3961847f8eSopenharmony_ci * @systemapi 4061847f8eSopenharmony_ci * @since 10 4161847f8eSopenharmony_ci */ 4261847f8eSopenharmony_cideclare namespace performanceMonitor { 4361847f8eSopenharmony_ci /** 4461847f8eSopenharmony_ci * Enumerates the input event type. 4561847f8eSopenharmony_ci * 4661847f8eSopenharmony_ci * @enum { number } 4761847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 4861847f8eSopenharmony_ci * @systemapi 4961847f8eSopenharmony_ci * @since 10 5061847f8eSopenharmony_ci */ 5161847f8eSopenharmony_ci export enum ActionType { 5261847f8eSopenharmony_ci /** 5361847f8eSopenharmony_ci * The user presses the finger on the screen. 5461847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 5561847f8eSopenharmony_ci * @systemapi 5661847f8eSopenharmony_ci * @since 10 5761847f8eSopenharmony_ci */ 5861847f8eSopenharmony_ci LAST_DOWN = 0, 5961847f8eSopenharmony_ci 6061847f8eSopenharmony_ci /** 6161847f8eSopenharmony_ci * The user lifts up the finger from the screen. 6261847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 6361847f8eSopenharmony_ci * @systemapi 6461847f8eSopenharmony_ci * @since 10 6561847f8eSopenharmony_ci */ 6661847f8eSopenharmony_ci LAST_UP = 1, 6761847f8eSopenharmony_ci 6861847f8eSopenharmony_ci /** 6961847f8eSopenharmony_ci * The user first moves the finger after pressing down the screen. 7061847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 7161847f8eSopenharmony_ci * @systemapi 7261847f8eSopenharmony_ci * @since 10 7361847f8eSopenharmony_ci */ 7461847f8eSopenharmony_ci FIRST_MOVE = 2 7561847f8eSopenharmony_ci } 7661847f8eSopenharmony_ci 7761847f8eSopenharmony_ci /** 7861847f8eSopenharmony_ci * Enumerates the input source type. 7961847f8eSopenharmony_ci * 8061847f8eSopenharmony_ci * @enum { number } 8161847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 8261847f8eSopenharmony_ci * @systemapi 8361847f8eSopenharmony_ci * @since 12 8461847f8eSopenharmony_ci */ 8561847f8eSopenharmony_ci export enum SourceType { 8661847f8eSopenharmony_ci /** 8761847f8eSopenharmony_ci * The user touches the screen to trigger the scene. 8861847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 8961847f8eSopenharmony_ci * @systemapi 9061847f8eSopenharmony_ci * @since 12 9161847f8eSopenharmony_ci */ 9261847f8eSopenharmony_ci PERF_TOUCH_EVENT = 0, 9361847f8eSopenharmony_ci 9461847f8eSopenharmony_ci /** 9561847f8eSopenharmony_ci * TThe user uses the mouse to trigger the scene. 9661847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 9761847f8eSopenharmony_ci * @systemapi 9861847f8eSopenharmony_ci * @since 12 9961847f8eSopenharmony_ci */ 10061847f8eSopenharmony_ci PERF_MOUSE_EVENT = 1, 10161847f8eSopenharmony_ci 10261847f8eSopenharmony_ci /** 10361847f8eSopenharmony_ci * The user uses the touchpad to trigger the scene. 10461847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 10561847f8eSopenharmony_ci * @systemapi 10661847f8eSopenharmony_ci * @since 12 10761847f8eSopenharmony_ci */ 10861847f8eSopenharmony_ci PERF_TOUCHPAD_EVENT = 2, 10961847f8eSopenharmony_ci 11061847f8eSopenharmony_ci /** 11161847f8eSopenharmony_ci * The user uses the joystick to trigger the scene. 11261847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 11361847f8eSopenharmony_ci * @systemapi 11461847f8eSopenharmony_ci * @since 12 11561847f8eSopenharmony_ci */ 11661847f8eSopenharmony_ci PERF_JOYSTICK_EVENT = 3, 11761847f8eSopenharmony_ci 11861847f8eSopenharmony_ci /** 11961847f8eSopenharmony_ci * The user uses the keyboard to trigger the scene. 12061847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 12161847f8eSopenharmony_ci * @systemapi 12261847f8eSopenharmony_ci * @since 12 12361847f8eSopenharmony_ci */ 12461847f8eSopenharmony_ci PERF_KEY_EVENT = 4 12561847f8eSopenharmony_ci } 12661847f8eSopenharmony_ci 12761847f8eSopenharmony_ci /** 12861847f8eSopenharmony_ci * Begin monitoring an application scene. 12961847f8eSopenharmony_ci * 13061847f8eSopenharmony_ci * @param { string } scene Indicates the scene name. 13161847f8eSopenharmony_ci * @param { ActionType } startInputType Indicates the scene input event type. 13261847f8eSopenharmony_ci * @param { string } note Indicates the app expected info delivered. 13361847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 13461847f8eSopenharmony_ci * @systemapi 13561847f8eSopenharmony_ci * @since 10 13661847f8eSopenharmony_ci */ 13761847f8eSopenharmony_ci function begin(scene: string, startInputType: ActionType, note?: string): void; 13861847f8eSopenharmony_ci 13961847f8eSopenharmony_ci /** 14061847f8eSopenharmony_ci * End monitoring an application scene. 14161847f8eSopenharmony_ci * 14261847f8eSopenharmony_ci * @param { string } scene Indicates the scene name. It must be the same with the {@code scene} of start. 14361847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 14461847f8eSopenharmony_ci * @systemapi 14561847f8eSopenharmony_ci * @since 10 14661847f8eSopenharmony_ci */ 14761847f8eSopenharmony_ci function end(scene: string): void; 14861847f8eSopenharmony_ci 14961847f8eSopenharmony_ci /** 15061847f8eSopenharmony_ci * recordInputEventTime monitoring an application scene. 15161847f8eSopenharmony_ci * 15261847f8eSopenharmony_ci * @param { ActionType } type - Indicates the scene input event type. 15361847f8eSopenharmony_ci * @param { SourceType } sourceType - Indicates the scene input source type. 15461847f8eSopenharmony_ci * @param { number } time - Indicates the scene input time. 15561847f8eSopenharmony_ci * @throws { BusinessError } 202 - not system application. 15661847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 15761847f8eSopenharmony_ci * @systemapi 15861847f8eSopenharmony_ci * @since 12 15961847f8eSopenharmony_ci */ 16061847f8eSopenharmony_ci function recordInputEventTime(type: ActionType, sourceType: SourceType, time: number): void; 16161847f8eSopenharmony_ci} 16261847f8eSopenharmony_ciexport default performanceMonitor; 163