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 * @namespace bytrace 38 * @syscap SystemCapability.HiviewDFX.HiTrace 39 * @since 7 40 * @deprecated since 8 41 * @useinstead ohos.hiTraceMeter 42 */ 43declare namespace bytrace { 44 /** 45 * Records a trace marking it as the start of a task, can with the expected completion time between 46 * startTrace and finishTrace. 47 * This method is invoked at the start of a transaction to indicate that a task has started, whose name 48 * is specified by {@code name}, and the taskId is used to distinguish the tasks. It must be followed by 49 * {@link #finishTrace}, the name and taskId need to be the same. 50 * 51 * @param { string } name Indicates the task name. 52 * @param { number } taskId The unique id used to distinguish the tasks and match with the id in follow finishTrace. 53 * @param { number } expectedTime Indicates the expected time required for completing the task, in milliseconds. 54 * @syscap SystemCapability.HiviewDFX.HiTrace 55 * @since 7 56 * @deprecated since 8 57 * @useinstead ohos.hiTraceMeter.startTrace 58 */ 59 function startTrace(name: string, taskId: number, expectedTime?: number): void; 60 61 /** 62 * Records a trace and marks it as the end of a task. 63 * 64 * This method is invoked at the end of a transaction to indicate that a task has ended, whose name 65 * is specified by {@code name}. This method must be invoked after the the startTrace. 66 * 67 * @param { string } name Indicates the task name. It must be the same with the {@code name} of startTrace. 68 * @param { number } taskId The unique id used to distinguish the tasks and must be the same with the . 69 * {@code taskId} of startTrace. 70 * @syscap SystemCapability.HiviewDFX.HiTrace 71 * @since 7 72 * @deprecated since 8 73 * @useinstead ohos.hiTraceMeter.finishTrace 74 */ 75 function finishTrace(name: string, taskId: number): void; 76 77 /** 78 * Records a trace for generating a count, such as clock pulse and the number of layers. 79 * 80 * @param { string } name Indicates the name used to identify the count. 81 * @param { number } count Indicates the number of the count. 82 * @syscap SystemCapability.HiviewDFX.HiTrace 83 * @since 7 84 * @deprecated since 8 85 * @useinstead ohos.hiTraceMeter.traceByValue 86 */ 87 function traceByValue(name: string, count: number): void; 88} 89export default bytrace;