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 * hiTraceMeter.startTrace("checkName", 111, 5); 26 * //your process 27 * hiTraceMeter.finishTrace("checkName", 111); 28 * }</pre> 29 * To trace the number of layers, which is 3: 30 * <pre>{@code 31 * hiTraceMeter.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 * @since 8 38 * @syscap SystemCapability.HiviewDFX.HiTrace 39 */ 40declare namespace hiTraceMeter { 41 /** 42 * Records a trace marking it as the start of a task, can with the expected completion time between 43 * startTrace and finishTrace. 44 * 45 * This method is invoked at the start of a transaction to indicate that a task has started, whose name 46 * is specified by {@code name}, and the taskId is used to distinguish the tasks. It must be followed by 47 * {@link #finishTrace}, the name and taskId need to be the same. 48 * 49 * @since 8 50 * @syscap SystemCapability.HiviewDFX.HiTrace 51 * @param name Indicates the task name. 52 * @param taskId The unique id used to distinguish the tasks and match with the id in follow finishTrace. 53 */ 54 function startTrace(name: string, taskId: number): void; 55 56 /** 57 * Records a trace and marks it as the end of a task. 58 * 59 * This method is invoked at the end of a transaction to indicate that a task has ended, whose name 60 * is specified by {@code name}. This method must be invoked after the the startTrace. 61 * 62 * @since 8 63 * @syscap SystemCapability.HiviewDFX.HiTrace 64 * @param name Indicates the task name. It must be the same with the {@code name} of startTrace. 65 * @param taskId The unique id used to distinguish the tasks and must be the same with the . 66 * {@code taskId} of startTrace. 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 * @since 8 74 * @syscap SystemCapability.HiviewDFX.HiTrace 75 * @param name Indicates the name used to identify the count. 76 * @param count Indicates the number of the count. 77 */ 78 function traceByValue(name: string, count: number): void; 79} 80 81export default hiTraceMeter;