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 * To trace a name verification that is expected to complete within 5 ms: 29 * <pre>{@code 30 * bytrace.startTrace("checkName", 111, 5); 31 * //your process 32 * bytrace.finishTrace("checkName", 111); 33 * }</pre> 34 * To trace the number of layers, which is 3: 35 * <pre>{@code 36 * bytrace.traceByValue("curLayer", 3); 37 * }</pre> 38 * 39 * <p>Each {@code startTrace} matches one {@code finishTrace}, and they must have the same name 40 * and taskId. 41 * 42 * @namespace bytrace 43 * @syscap SystemCapability.HiviewDFX.HiTrace 44 * @since 7 45 * @deprecated since 8 46 * @useinstead ohos.hiTraceMeter 47 */ 48declare namespace bytrace { 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 * This method is invoked at the start of a transaction to indicate that a task has started, whose name 53 * is specified by {@code name}, and the taskId is used to distinguish the tasks. It must be followed by 54 * {@link #finishTrace}, the name and taskId need to be the same. 55 * 56 * @param { string } name Indicates the task name. 57 * @param { number } taskId The unique id used to distinguish the tasks and match with the id in follow finishTrace. 58 * @param { number } expectedTime Indicates the expected time required for completing the task, in milliseconds. 59 * @syscap SystemCapability.HiviewDFX.HiTrace 60 * @since 7 61 * @deprecated since 8 62 * @useinstead ohos.hiTraceMeter.startTrace 63 */ 64 function startTrace(name: string, taskId: number, expectedTime?: number): void; 65 66 /** 67 * Records a trace and marks it as the end of a task. 68 * 69 * This method is invoked at the end of a transaction to indicate that a task has ended, whose name 70 * is specified by {@code name}. This method must be invoked after the the startTrace. 71 * 72 * @param { string } name Indicates the task name. It must be the same with the {@code name} of startTrace. 73 * @param { number } taskId The unique id used to distinguish the tasks and must be the same with the . 74 * {@code taskId} of startTrace. 75 * @syscap SystemCapability.HiviewDFX.HiTrace 76 * @since 7 77 * @deprecated since 8 78 * @useinstead ohos.hiTraceMeter.finishTrace 79 */ 80 function finishTrace(name: string, taskId: number): void; 81 82 /** 83 * Records a trace for generating a count, such as clock pulse and the number of layers. 84 * 85 * @param { string } name Indicates the name used to identify the count. 86 * @param { number } count Indicates the number of the count. 87 * @syscap SystemCapability.HiviewDFX.HiTrace 88 * @since 7 89 * @deprecated since 8 90 * @useinstead ohos.hiTraceMeter.traceByValue 91 */ 92 function traceByValue(name: string, count: number): void; 93} 94export default bytrace;