1/* 2 * Copyright (c) 2022 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 16import bytrace from '@ohos.bytrace' 17 18// Used to track the start of sequential tasks 19export function startTrace(name: string): void { 20 bytrace.startTrace(name, 1); 21} 22 23// Used to track the end of sequential tasks. The name must be the same as that at start 24export function finishTrace(name: string): void { 25 bytrace.finishTrace(name, 1); 26} 27 28// Used to track the start of cross tasks 29// (scenarios where the next task starts before the previous task is finished) 30export function startTraceWithTaskId(name: string, taskId: number): void { 31 bytrace.startTrace(name, taskId); 32} 33 34// Used to track the end of cross tasks. The name and taskId must be the same as at start 35export function finishTraceWithTaskId(name: string, taskId: number): void { 36 bytrace.finishTrace(name, taskId); 37}