161847f8eSopenharmony_ci/* 261847f8eSopenharmony_ci * Copyright (C) 2021 Huawei Device Co., Ltd. 361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 461847f8eSopenharmony_ci * you may not use this file except in compliance with the License. 561847f8eSopenharmony_ci * You may obtain a copy of the License at 661847f8eSopenharmony_ci * 761847f8eSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 861847f8eSopenharmony_ci * 961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and 1361847f8eSopenharmony_ci * limitations under the License. 1461847f8eSopenharmony_ci */ 1561847f8eSopenharmony_ci 1661847f8eSopenharmony_ci/** 1761847f8eSopenharmony_ci * @file 1861847f8eSopenharmony_ci * @kit PerformanceAnalysisKit 1961847f8eSopenharmony_ci */ 2061847f8eSopenharmony_ci 2161847f8eSopenharmony_ci/** 2261847f8eSopenharmony_ci * Provides interfaces to trace a task for performance measure, the logs can be capture by the 2361847f8eSopenharmony_ci * bytrace cmdline available on the device. 2461847f8eSopenharmony_ci * 2561847f8eSopenharmony_ci * <p>This interfaces trace the start, end, and value changes of key processes that last for at least 3 ms. 2661847f8eSopenharmony_ci * 2761847f8eSopenharmony_ci * <p>Example: 2861847f8eSopenharmony_ci * Track the beginning of a context: 2961847f8eSopenharmony_ci * <pre>{@code 3061847f8eSopenharmony_ci * hiTraceMeter.startTrace("checkName", 111); 3161847f8eSopenharmony_ci * }</pre> 3261847f8eSopenharmony_ci * Track the end of a context: 3361847f8eSopenharmony_ci * <pre>{@code 3461847f8eSopenharmony_ci * hiTraceMeter.finishTrace("checkName", 111); 3561847f8eSopenharmony_ci * }</pre> 3661847f8eSopenharmony_ci * To trace the number of layers, which is 3: 3761847f8eSopenharmony_ci * <pre>{@code 3861847f8eSopenharmony_ci * hiTraceMeter.traceByValue("curLayer", 3); 3961847f8eSopenharmony_ci * }</pre> 4061847f8eSopenharmony_ci * 4161847f8eSopenharmony_ci * <p>Each {@code startTrace} matches one {@code finishTrace}, and they must have the same name 4261847f8eSopenharmony_ci * and taskId. 4361847f8eSopenharmony_ci * 4461847f8eSopenharmony_ci * @namespace hiTraceMeter 4561847f8eSopenharmony_ci * @syscap SystemCapability.HiviewDFX.HiTrace 4661847f8eSopenharmony_ci * @since 8 4761847f8eSopenharmony_ci */ 4861847f8eSopenharmony_cideclare namespace hiTraceMeter { 4961847f8eSopenharmony_ci /** 5061847f8eSopenharmony_ci * Records a trace marking it as the start of a task, can with the expected completion time between 5161847f8eSopenharmony_ci * startTrace and finishTrace. 5261847f8eSopenharmony_ci * 5361847f8eSopenharmony_ci * This method is invoked at the start of a transaction to indicate that a task has started, whose name 5461847f8eSopenharmony_ci * is specified by {@code name}, and the taskId is used to distinguish the tasks. It must be followed by 5561847f8eSopenharmony_ci * {@link #finishTrace}, the name and taskId need to be the same. 5661847f8eSopenharmony_ci * 5761847f8eSopenharmony_ci * @param { string } name Indicates the task name. 5861847f8eSopenharmony_ci * @param { number } taskId The unique id used to distinguish the tasks and match with the id in follow finishTrace. 5961847f8eSopenharmony_ci * @syscap SystemCapability.HiviewDFX.HiTrace 6061847f8eSopenharmony_ci * @since 8 6161847f8eSopenharmony_ci */ 6261847f8eSopenharmony_ci function startTrace(name: string, taskId: number): void; 6361847f8eSopenharmony_ci 6461847f8eSopenharmony_ci /** 6561847f8eSopenharmony_ci * Records a trace and marks it as the end of a task. 6661847f8eSopenharmony_ci * 6761847f8eSopenharmony_ci * This method is invoked at the end of a transaction to indicate that a task has ended, whose name 6861847f8eSopenharmony_ci * is specified by {@code name}. This method must be invoked after the the startTrace. 6961847f8eSopenharmony_ci * 7061847f8eSopenharmony_ci * @param { string } name Indicates the task name. It must be the same with the {@code name} of startTrace. 7161847f8eSopenharmony_ci * @param { number } taskId The unique id used to distinguish the tasks and must be the same with the . 7261847f8eSopenharmony_ci * {@code taskId} of startTrace. 7361847f8eSopenharmony_ci * @syscap SystemCapability.HiviewDFX.HiTrace 7461847f8eSopenharmony_ci * @since 8 7561847f8eSopenharmony_ci */ 7661847f8eSopenharmony_ci function finishTrace(name: string, taskId: number): void; 7761847f8eSopenharmony_ci 7861847f8eSopenharmony_ci /** 7961847f8eSopenharmony_ci * Records a trace for generating a count, such as clock pulse and the number of layers. 8061847f8eSopenharmony_ci * 8161847f8eSopenharmony_ci * @param { string } name Indicates the name used to identify the count. 8261847f8eSopenharmony_ci * @param { number } count Indicates the number of the count. 8361847f8eSopenharmony_ci * @syscap SystemCapability.HiviewDFX.HiTrace 8461847f8eSopenharmony_ci * @since 8 8561847f8eSopenharmony_ci */ 8661847f8eSopenharmony_ci function traceByValue(name: string, count: number): void; 8761847f8eSopenharmony_ci} 8861847f8eSopenharmony_ci 8961847f8eSopenharmony_ciexport default hiTraceMeter; 90