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 * To trace a name verification that is expected to complete within 5 ms:
2961847f8eSopenharmony_ci * <pre>{@code
3061847f8eSopenharmony_ci * bytrace.startTrace("checkName", 111, 5);
3161847f8eSopenharmony_ci * //your process
3261847f8eSopenharmony_ci * bytrace.finishTrace("checkName", 111);
3361847f8eSopenharmony_ci * }</pre>
3461847f8eSopenharmony_ci * To trace the number of layers, which is 3:
3561847f8eSopenharmony_ci * <pre>{@code
3661847f8eSopenharmony_ci * bytrace.traceByValue("curLayer", 3);
3761847f8eSopenharmony_ci * }</pre>
3861847f8eSopenharmony_ci *
3961847f8eSopenharmony_ci * <p>Each {@code startTrace} matches one {@code finishTrace}, and they must have the same name
4061847f8eSopenharmony_ci * and taskId.
4161847f8eSopenharmony_ci *
4261847f8eSopenharmony_ci * @namespace bytrace
4361847f8eSopenharmony_ci * @syscap SystemCapability.HiviewDFX.HiTrace
4461847f8eSopenharmony_ci * @since 7
4561847f8eSopenharmony_ci * @deprecated since 8
4661847f8eSopenharmony_ci * @useinstead ohos.hiTraceMeter
4761847f8eSopenharmony_ci */
4861847f8eSopenharmony_cideclare namespace bytrace {
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   * This method is invoked at the start of a transaction to indicate that a task has started, whose name
5361847f8eSopenharmony_ci   * is specified by {@code name}, and the taskId is used to distinguish the tasks. It must be followed by
5461847f8eSopenharmony_ci   * {@link #finishTrace}, the name and taskId need to be the same.
5561847f8eSopenharmony_ci   *
5661847f8eSopenharmony_ci   * @param { string } name Indicates the task name.
5761847f8eSopenharmony_ci   * @param { number } taskId The unique id used to distinguish the tasks and match with the id in follow finishTrace.
5861847f8eSopenharmony_ci   * @param { number } expectedTime Indicates the expected time required for completing the task, in milliseconds.
5961847f8eSopenharmony_ci   * @syscap SystemCapability.HiviewDFX.HiTrace
6061847f8eSopenharmony_ci   * @since 7
6161847f8eSopenharmony_ci   * @deprecated since 8
6261847f8eSopenharmony_ci   * @useinstead ohos.hiTraceMeter.startTrace
6361847f8eSopenharmony_ci   */
6461847f8eSopenharmony_ci  function startTrace(name: string, taskId: number, expectedTime?: number): void;
6561847f8eSopenharmony_ci
6661847f8eSopenharmony_ci  /**
6761847f8eSopenharmony_ci   * Records a trace and marks it as the end of a task.
6861847f8eSopenharmony_ci   *
6961847f8eSopenharmony_ci   * This method is invoked at the end of a transaction to indicate that a task has ended, whose name
7061847f8eSopenharmony_ci   * is specified by {@code name}. This method must be invoked after the the startTrace.
7161847f8eSopenharmony_ci   *
7261847f8eSopenharmony_ci   * @param { string } name Indicates the task name. It must be the same with the {@code name} of startTrace.
7361847f8eSopenharmony_ci   * @param { number } taskId The unique id used to distinguish the tasks and must be the same with the .
7461847f8eSopenharmony_ci   * {@code taskId} of startTrace.
7561847f8eSopenharmony_ci   * @syscap SystemCapability.HiviewDFX.HiTrace
7661847f8eSopenharmony_ci   * @since 7
7761847f8eSopenharmony_ci   * @deprecated since 8
7861847f8eSopenharmony_ci   * @useinstead ohos.hiTraceMeter.finishTrace
7961847f8eSopenharmony_ci   */
8061847f8eSopenharmony_ci  function finishTrace(name: string, taskId: number): void;
8161847f8eSopenharmony_ci
8261847f8eSopenharmony_ci  /**
8361847f8eSopenharmony_ci   * Records a trace for generating a count, such as clock pulse and the number of layers.
8461847f8eSopenharmony_ci   *
8561847f8eSopenharmony_ci   * @param { string } name Indicates the name used to identify the count.
8661847f8eSopenharmony_ci   * @param { number } count Indicates the number of the count.
8761847f8eSopenharmony_ci   * @syscap SystemCapability.HiviewDFX.HiTrace
8861847f8eSopenharmony_ci   * @since 7
8961847f8eSopenharmony_ci   * @deprecated since 8
9061847f8eSopenharmony_ci   * @useinstead ohos.hiTraceMeter.traceByValue
9161847f8eSopenharmony_ci   */
9261847f8eSopenharmony_ci  function traceByValue(name: string, count: number): void;
9361847f8eSopenharmony_ci}
9461847f8eSopenharmony_ciexport default bytrace;