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