1/* 2 * Copyright (C) 2021 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 * Provides interfaces to trace a task for performance measure, the logs can be capture by the 18 * bytrace cmdline available on the device. 19 * 20 * <p>This interfaces trace the start, end, and value changes of key processes that last for at least 3 ms. 21 * 22 * <p>Example: 23 * To trace a name verification that is expected to complete within 5 ms: 24 * <pre>{@code 25 * bytrace.startTrace("checkName", 111, 5); 26 * //your process 27 * bytrace.finishTrace("checkName", 111); 28 * }</pre> 29 * To trace the number of layers, which is 3: 30 * <pre>{@code 31 * bytrace.traceByValue("curLayer", 3); 32 * }</pre> 33 * 34 * <p>Each {@code startTrace} matches one {@code finishTrace}, and they must have the same name 35 * and taskId. 36 * 37 * @SysCap SystemCapability.Developtools.Bytrace 38 * @devices phone, tablet 39 * @since 7 40 */ 41declare namespace bytrace { 42 /** 43 * Records a trace marking it as the start of a task, can with the expected completion time between 44 * startTrace and finishTrace. 45 * 46 * This method is invoked at the start of a transaction to indicate that a task has started, whose name 47 * is specified by {@code name}, and the taskId is used to distinguish the tasks. It must be followed by 48 * {@link #finishTrace}, the name and taskId need to be the same. 49 * 50 * @param name Indicates the task name. 51 * @param taskId The unique id used to distinguish the tasks and match with the id in follow finishTrace. 52 * @param expectedTime Indicates the expected time required for completing the task, in milliseconds. 53 * @since 7 54 */ 55 function startTrace(name: string, taskId: number, expectedTime?: number): void; 56 57 /** 58 * Records a trace and marks it as the end of a task. 59 * 60 * This method is invoked at the end of a transaction to indicate that a task has ended, whose name 61 * is specified by {@code name}. This method must be invoked after the the startTrace. 62 * 63 * @param name Indicates the task name. It must be the same whith the {@code name} of startTrace. 64 * @param taskId The unique id used to distinguish the tasks and must be the same whith the . 65 * {@code taskId} of startTrace. 66 * @since 7 67 */ 68 function finishTrace(name: string, taskId: number): void; 69 70 /** 71 * Records a trace for generating a count, such as clock pulse and the number of layers. 72 * 73 * @param name Indicates the name used to identify the count. 74 * @param count Indicates the number of the count. 75 * @since 7 76 */ 77 function traceByValue(name: string, count: number): void; 78} 79export default bytrace;