提交 89962173 编写于 作者: S shawn_he

update doc

Signed-off-by: Nshawn_he <shawn.he@huawei.com>
上级 327257b0
...@@ -17,11 +17,11 @@ hiTraceMeter provides APIs for system performance tracing. You can call the APIs ...@@ -17,11 +17,11 @@ hiTraceMeter provides APIs for system performance tracing. You can call the APIs
## Constraints ## Constraints
Due to the asynchronous I/O feature of JS, the hiTraceMeter module provides only asynchronous APIs. - Due to the asynchronous I/O feature of JS, the hiTraceMeter module provides only asynchronous APIs.
## Available APIs ## Available APIs
The performance tracing APIs are provided by the **hiTraceMeter** module. For details, see [API Reference](../reference/apis/js-apis-hitracemeter.md). The performance tracing APIs are provided by the **hiTraceMeter** module. For details, see [API Reference]( ../reference/apis/js-apis-hitracemeter.md).
**APIs for performance tracing** **APIs for performance tracing**
...@@ -35,114 +35,120 @@ The performance tracing APIs are provided by the **hiTraceMeter** module. For de ...@@ -35,114 +35,120 @@ The performance tracing APIs are provided by the **hiTraceMeter** module. For de
In this example, distributed call chain tracing begins when the application startup execution page is loaded and stops when the service usage is completed. In this example, distributed call chain tracing begins when the application startup execution page is loaded and stops when the service usage is completed.
1. Create a JS application project. In the displayed **Project** window, choose **entry** > **src** > **main** > **js** > **default** > **pages** > **index**, and double-click **index.js**. Add the code to implement performance tracing upon page loading. The sample code is as follows: 1. Create a project, and call hiTraceMeter APIs in the service logic to implement performance tracing.
```js
import hiTraceMeter from '@ohos.hiTraceMeter'
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
// Start trace tasks with the same name concurrently.
hiTraceMeter.startTrace("business", 1);
// Keep the service process running.
console.log(`business running`);
hiTraceMeter.startTrace("business", 2); // Start the second trace task with the same name while the first task is still running. The tasks are running concurrently and therefore their taskId must be different.
// Keep the service process running.
console.log(`business running`);
hiTraceMeter.finishTrace("business", 1);
// Keep the service process running.
console.log(`business running`);
hiTraceMeter.finishTrace("business", 2);
// Start trace tasks with the same name in serial mode.
hiTraceMeter.startTrace("business", 1);
// Keep the service process running.
console.log(`business running`);
hiTraceMeter.finishTrace("business", 1); // End the first trace task.
// Keep the service process running.
console.log(`business running`);
hiTraceMeter.startTrace("business", 1); // Start the second trace task with the same name in serial mode.
// Keep the service process running.
console.log(`business running`);
let traceCount = 3;
hiTraceMeter.traceByValue("myTestCount", traceCount);
traceCount = 4;
hiTraceMeter.traceByValue("myTestCount", traceCount);
hiTraceMeter.finishTrace("business", 1);
}
}
```
2. Create an ArkTs application project. In the displayed **Project** window, choose **entry** > **src** > **main** > **ets** > **pages** > **index**, and double-click **index.js**. Add the code to implement performance tracing upon page loading. For example, if the name of the trace task is **HITRACE\_TAG\_APP**, the sample code is as follows:
```ts
import hitrace from '@ohos.hiTraceMeter';
@Entry
@Component
struct Index {
@State message: string = 'Hello World';
build() { - **ArkTS application project**
Row() {
Column() { Create an ArkTS application project. In the displayed **Project** window, choose **entry** > **src** > **main** > **ets** > **pages** > **index**, and double-click **index.js**. Add the code to implement performance tracing upon page loading. For example, if the name of the trace task is **HITRACE\_TAG\_APP**, the sample code is as follows:
Text(this.message)
.fontSize(50) ```ts
.fontWeight(FontWeight.Bold) import hitrace from '@ohos.hiTraceMeter';
.onClick(() => {
this.message = 'Hello ArkUI'; @Entry
@Component
// Start trace tasks with the same name concurrently. struct Index {
hitrace.startTrace("HITRACE_TAG_APP", 1001); @State message: string = 'Hello World';
// Keep the service process running.
console.log(`HITRACE_TAG_APP running`); build() {
Row() {
// Start the second trace task with the same name while the first task is still running. The tasks are running concurrently and therefore their taskId must be different. Column() {
hitrace.startTrace("HITRACE_TAG_APP", 1002); Text(this.message)
// Keep the service process running. .fontSize(50)
console.log(`HITRACE_TAG_APP running`); .fontWeight(FontWeight.Bold)
.onClick(() => {
hitrace.finishTrace("HITRACE_TAG_APP", 1001); this.message = 'Hello ArkUI';
hitrace.finishTrace("HITRACE_TAG_APP", 1002);
// Start trace tasks with the same name concurrently.
// If trace tasks with the same name are not run concurrently, the same taskId can be used. hitrace.startTrace("HITRACE_TAG_APP", 1001);
hitrace.startTrace("HITRACE_TAG_APP", 1003); // Keep the service process running.
// Keep the service process running. console.log(`HITRACE_TAG_APP running`);
console.log(`HITRACE_TAG_APP running`);
// End the first trace task. // Start the second trace task with the same name while the first task is still running. The tasks are running concurrently and therefore their taskId must be different.
hitrace.finishTrace("HITRACE_TAG_APP", 1003); hitrace.startTrace("HITRACE_TAG_APP", 1002);
// Keep the service process running.
// Start the second trace task with the same name in serial mode. It uses a taskId different from the first trace task. console.log(`HITRACE_TAG_APP running`);
hitrace.startTrace("HITRACE_TAG_APP", 1004);
// Keep the service process running. hitrace.finishTrace("HITRACE_TAG_APP", 1001);
console.log(`HITRACE_TAG_APP running`); hitrace.finishTrace("HITRACE_TAG_APP", 1002);
let traceCount = 3;
hitrace.traceByValue("myTestCount", traceCount); // If trace tasks with the same name are not run concurrently, the same taskId can be used.
hitrace.finishTrace("HITRACE_TAG_APP", 1004); hitrace.startTrace("HITRACE_TAG_APP", 1003);
// Keep the service process running.
// Start the third trace task with the same name in serial mode. It uses a taskId same as the second trace task. console.log(`HITRACE_TAG_APP running`);
hitrace.startTrace("HITRACE_TAG_APP", 1004); // End the first trace task.
// Keep the service process running. hitrace.finishTrace("HITRACE_TAG_APP", 1003);
console.log(`HITRACE_TAG_APP running`);
// End the third trace task. // Start the second trace task with the same name in serial mode. It uses a taskId different from the first trace task.
hitrace.finishTrace("HITRACE_TAG_APP", 1004); hitrace.startTrace("HITRACE_TAG_APP", 1004);
// Keep the service process running.
}) console.log(`HITRACE_TAG_APP running`);
let traceCount = 3;
hitrace.traceByValue("myTestCount", traceCount);
hitrace.finishTrace("HITRACE_TAG_APP", 1004);
// Start the third trace task with the same name in serial mode. It uses a taskId same as the second trace task.
hitrace.startTrace("HITRACE_TAG_APP", 1004);
// Keep the service process running.
console.log(`HITRACE_TAG_APP running`);
// End the third trace task.
hitrace.finishTrace("HITRACE_TAG_APP", 1004);
})
}
.width('100%')
}
.height('100%')
} }
.width('100%')
}
.height('100%')
} }
} ```
```
- **JS application project**
3. Click the run button on the application page. Then, run the following commands in sequence in shell:
Create a JS application project. In the displayed **Project** window, choose **entry** > **src** > **main** > **js** > **default** > **pages** > **index**, and double-click **index.js**. Add the code to implement performance tracing upon page loading. The sample code is as follows:
```js
import hiTraceMeter from '@ohos.hiTraceMeter'
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
// Start trace tasks with the same name concurrently.
hiTraceMeter.startTrace("business", 1);
// Keep the service process running.
console.log(`business running`);
hiTraceMeter.startTrace("business", 2); // Start the second trace task with the same name while the first task is still running. The tasks are running concurrently and therefore their taskId must be different.
// Keep the service process running.
console.log(`business running`);
hiTraceMeter.finishTrace("business", 1);
// Keep the service process running.
console.log(`business running`);
hiTraceMeter.finishTrace("business", 2);
// Start trace tasks with the same name in serial mode.
hiTraceMeter.startTrace("business", 1);
// Keep the service process running.
console.log(`business running`);
hiTraceMeter.finishTrace("business", 1); // End the first trace task.
// Keep the service process running.
console.log(`business running`);
hiTraceMeter.startTrace("business", 1); // Start the second trace task with the same name in serial mode.
// Keep the service process running.
console.log(`business running`);
let traceCount = 3;
hiTraceMeter.traceByValue("myTestCount", traceCount);
traceCount = 4;
hiTraceMeter.traceByValue("myTestCount", traceCount);
hiTraceMeter.finishTrace("business", 1);
}
}
```
2. Click the run button on the application page. Then, run the following commands in sequence in shell:
```shell ```shell
hdc shell hdc shell
......
# i18n Error Codes # I18N Error Codes
> **NOTE** > **NOTE**
> >
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
**Error Message** **Error Message**
Unspported para value. param value not valid
**Description** **Description**
...@@ -21,21 +21,3 @@ Invalid parameter values are probably due to incorrect parameter types. ...@@ -21,21 +21,3 @@ Invalid parameter values are probably due to incorrect parameter types.
**Solution** **Solution**
Check whether the parameter type is correct. Check whether the parameter type is correct.
## 890002 Incorrect Configuration Option
**Error Message**
Unspported option value.
**Description**
This error code is reported if an I18N API is called with invalid option values specified.
**Possible Causes**
Invalid option values are probably due to incorrect option types.
**Solution**
Check whether the option type is correct.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册