提交 596ddb93 编写于 作者: S shawn_he

update doc

Signed-off-by: Nshawn_he <shawn.he@huawei.com>
上级 6e4bc0f8
# Performance Tracing # Performance Tracing
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**
> - The APIs of this module are no longer maintained since API version 8. It is recommended that you use the APIs of [hiTraceMeter](js-apis-hitracemeter.md) instead. > - The APIs of this module are no longer maintained since API version 8. It is recommended that you use the APIs of [hiTraceMeter](js-apis-hitracemeter.md) instead.
> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
``` ```js
import bytrace from '@ohos.bytrace'; import bytrace from '@ohos.bytrace';
``` ```
...@@ -17,7 +17,11 @@ import bytrace from '@ohos.bytrace'; ...@@ -17,7 +17,11 @@ import bytrace from '@ohos.bytrace';
startTrace(name: string, taskId: number, expectedTime?: number): void startTrace(name: string, taskId: number, expectedTime?: number): void
Starts a trace task. **expectedTime** is an optional parameter, which specifies the expected duration of the trace. Marks the start of a timeslice trace task.
> **NOTE**
>
> If multiple trace tasks with the same name need to be performed at the same time or a trace task needs to be performed multiple times concurrently, different task IDs must be specified in **startTrace**. If the trace tasks with the same name are not performed at the same time, the same taskId can be used. For details, see the bytrace.finishTrace example.
**System capability**: SystemCapability.Developtools.Bytrace **System capability**: SystemCapability.Developtools.Bytrace
...@@ -25,16 +29,14 @@ Starts a trace task. **expectedTime** is an optional parameter, which specifies ...@@ -25,16 +29,14 @@ Starts a trace task. **expectedTime** is an optional parameter, which specifies
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| name | string | Yes| Name of the trace task to start.| | name | string | Yes| Name of a timeslice trace task.|
| taskId | number | Yes| Task ID.| | taskId | number | Yes| ID of a timeslice trace task.|
| expectedTime | number | No| Expected duration of the trace, in ms.| | expectedTime | number | No| Expected duration of the trace, in ms.|
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> If multiple trace tasks with the same name need to be performed at the same time or a trace task needs to be performed multiple times concurrently, different task IDs must be specified in **startTrace**. If the trace tasks with the same name are not performed at the same time, the same taskId can be used. For details, see the bytrace.finishTrace example.
**Example** **Example**
``` ```js
bytrace.startTrace("myTestFunc", 1); bytrace.startTrace("myTestFunc", 1);
bytrace.startTrace("myTestFunc", 1, 5); // The expected duration of the trace is 5 ms. bytrace.startTrace("myTestFunc", 1, 5); // The expected duration of the trace is 5 ms.
``` ```
...@@ -44,7 +46,11 @@ bytrace.startTrace("myTestFunc", 1, 5); // The expected duration of the trace is ...@@ -44,7 +46,11 @@ bytrace.startTrace("myTestFunc", 1, 5); // The expected duration of the trace is
finishTrace(name: string, taskId: number): void finishTrace(name: string, taskId: number): void
Stops a trace task. Marks the end of a timeslice trace task.
> **NOTE**
>
> To stop a trace task, the values of name and task ID in **finishTrace** must be the same as those in **startTrace**.
**System capability**: SystemCapability.Developtools.Bytrace **System capability**: SystemCapability.Developtools.Bytrace
...@@ -52,15 +58,13 @@ Stops a trace task. ...@@ -52,15 +58,13 @@ Stops a trace task.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| name | string | Yes| Name of the trace task to start.| | name | string | Yes| Name of a timeslice trace task.|
| taskId | number | Yes| Task ID.| | taskId | number | Yes| ID of a timeslice trace task.|
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> To stop a trace task, the values of name and task ID in **finishTrace** must be the same as those in **startTrace**.
**Example** **Example**
``` ```js
bytrace.finishTrace("myTestFunc", 1); bytrace.finishTrace("myTestFunc", 1);
``` ```
...@@ -91,9 +95,9 @@ bytrace.finishTrace("myTestFunc", 1); ...@@ -91,9 +95,9 @@ bytrace.finishTrace("myTestFunc", 1);
traceByValue(name: string, count: number): void traceByValue(name: string, count: number): void
Traces the value changes of a variable. Defines the variable that indicates the number of timeslice trace tasks.
**System capability**: SystemCapability.Developtools.Bytrace **System capability**: SystemCapability.HiviewDFX.HiTrace
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -103,7 +107,7 @@ Traces the value changes of a variable. ...@@ -103,7 +107,7 @@ Traces the value changes of a variable.
**Example** **Example**
``` ```js
let traceCount = 3; let traceCount = 3;
bytrace.traceByValue("myTestCount", traceCount); bytrace.traceByValue("myTestCount", traceCount);
traceCount = 4; traceCount = 4;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册