diff --git a/zh-cn/application-dev/dfx/hidebug-guidelines-arkts.md b/zh-cn/application-dev/dfx/hidebug-guidelines-arkts.md
index c6b477fac750c63d76d23e02872639ebfe51fe6f..865987b2228414253c2cf59345023c15797e0c84 100644
--- a/zh-cn/application-dev/dfx/hidebug-guidelines-arkts.md
+++ b/zh-cn/application-dev/dfx/hidebug-guidelines-arkts.md
@@ -44,9 +44,14 @@ HiDebug的具体用法可查看API参考[API参考文档](../reference/apis-perf
新增一个方法调用hidebug接口,本文以hidebug.getSystemCpuUsage()为例,其他接口可参考[API参考文档](../reference/apis-performance-analysis-kit/js-apis-hidebug.md)。
```ts
- import { hidebug, hilog } from '@kit.PerformanceAnalysisKit';
+ import { hidebug } from '@kit.PerformanceAnalysisKit';
+ import { BusinessError } from '@kit.BasicServicesKit';
function testHidebug(event?: ClickEvent) {
- hilog.info(0x0000, "testTag", `getCurrentCpuUsage ${hidebug.getSystemCpuUsage()}`);
+ try {
+ console.info(`getSystemCpuUsage: ${hidebug.getSystemCpuUsage()}`)
+ } catch (error) {
+ console.error(`error code: ${(error as BusinessError).code}, error msg: ${(error as BusinessError).message}`);
+ }
}
```
@@ -78,7 +83,7 @@ HiDebug的具体用法可查看API参考[API参考文档](../reference/apis-perf
5. 在DevEco Studio的底部,切换到“Log”窗口,设置日志的过滤条件为“testTag”。
此时窗口将显示通过hidebug.getSystemCpuUsage()接口获取的CPU使用率的相关日志。
```Text
- 06-25 19:50:27.485 24645-24645/com.example.myapplication I A00000/testTag: getCurrentCpuUsage 0.10164512338425381
+ 08-20 11:06:01.891 1948-1948 A03d00/JSAPP com.examp...lication I getSystemCpuUsage: 0.4722222222222222
```
diff --git a/zh-cn/application-dev/reference/apis-performance-analysis-kit/hidebug__type_8h.md b/zh-cn/application-dev/reference/apis-performance-analysis-kit/hidebug__type_8h.md
index 3dcff1f00d3ba184fe09e3d749d21f71a1ec60dd..eac5abd99a5f9a7f80825452ab9c0cbd47571082 100644
--- a/zh-cn/application-dev/reference/apis-performance-analysis-kit/hidebug__type_8h.md
+++ b/zh-cn/application-dev/reference/apis-performance-analysis-kit/hidebug__type_8h.md
@@ -82,7 +82,7 @@ HiDebug模块代码结构体定义。
### 枚举
-| 名称 | 描述 |
-| -------- | -------- |
-| [HiDebug_ErrorCode](_hi_debug.md#hidebug_errorcode-1) {
HIDEBUG_SUCCESS = 0,
HIDEBUG_INVALID_ARGUMENT = 401,
HIDEBUG_TRACE_CAPTURED_ALREADY = 11400102,
HIDEBUG_NO_PERMISSION = 11400103,
HIDEBUG_TRACE_ABNORMAL = 11400104,
HIDEBUG_NO_TRACE_RUNNING = 11400105
} | 错误码定义 |
+| 名称 | 描述 |
+| -------- |----------|
+| [HiDebug_ErrorCode](_hi_debug.md#hidebug_errorcode-1) {
HIDEBUG_SUCCESS = 0,
HIDEBUG_INVALID_ARGUMENT = 401,
HIDEBUG_TRACE_CAPTURED_ALREADY = 11400102,
HIDEBUG_NO_PERMISSION = 11400103,
HIDEBUG_TRACE_ABNORMAL = 11400104,
HIDEBUG_NO_TRACE_RUNNING = 11400105
} | 错误码定义。 |
| [HiDebug_TraceFlag](_hi_debug.md#hidebug_traceflag-1) {
HIDEBUG_TRACE_FLAG_MAIN_THREAD = 1, HIDEBUG_TRACE_FLAG_ALL_THREADS = 2
} | 采集trace线程的类型。 |
diff --git a/zh-cn/application-dev/reference/apis-performance-analysis-kit/js-apis-hidebug.md b/zh-cn/application-dev/reference/apis-performance-analysis-kit/js-apis-hidebug.md
index 1529968b79edd1dcacaa61f84d22ace31a0a13a5..a93e8c9f55ad8f2188150e7ac85bed9f64f8eade 100644
--- a/zh-cn/application-dev/reference/apis-performance-analysis-kit/js-apis-hidebug.md
+++ b/zh-cn/application-dev/reference/apis-performance-analysis-kit/js-apis-hidebug.md
@@ -224,10 +224,10 @@ import { BusinessError } from '@kit.BasicServicesKit';
let applicationContext: common.Context | null = null;
try {
- let context = getContext() as common.UIAbilityContext;
- applicationContext = context.getApplicationContext();
+ let context = getContext() as common.UIAbilityContext;
+ applicationContext = context.getApplicationContext();
} catch (error) {
- console.info(`error code: ${(error as BusinessError).code}, error msg: ${(error as BusinessError).message}`);
+ console.error(`error code: ${(error as BusinessError).code}, error msg: ${(error as BusinessError).message}`);
}
let filesDir: string = applicationContext!.filesDir;
@@ -238,9 +238,9 @@ let serviceId: number = 10;
let args: Array = new Array("allInfo");
try {
- hidebug.getServiceDump(serviceId, file.fd, args);
+ hidebug.getServiceDump(serviceId, file.fd, args);
} catch (error) {
- console.info(`error code: ${(error as BusinessError).code}, error msg: ${(error as BusinessError).message}`);
+ console.error(`error code: ${(error as BusinessError).code}, error msg: ${(error as BusinessError).message}`);
}
fileIo.closeSync(file);
```
@@ -278,7 +278,7 @@ try {
// ...
hidebug.stopJsCpuProfiling();
} catch (error) {
- console.info(`error code: ${(error as BusinessError).code}, error msg: ${(error as BusinessError).message}`);
+ console.error(`error code: ${(error as BusinessError).code}, error msg: ${(error as BusinessError).message}`);
}
```
@@ -301,7 +301,7 @@ try {
// ...
hidebug.stopJsCpuProfiling();
} catch (error) {
- console.info(`error code: ${(error as BusinessError).code}, error msg: ${(error as BusinessError).message}`);
+ console.error(`error code: ${(error as BusinessError).code}, error msg: ${(error as BusinessError).message}`);
}
```
@@ -336,7 +336,7 @@ import { BusinessError } from '@kit.BasicServicesKit';
try {
hidebug.dumpJsHeapData("heapData");
} catch (error) {
- console.info(`error code: ${(error as BusinessError).code}, error msg: ${(error as BusinessError).message}`);
+ console.error(`error code: ${(error as BusinessError).code}, error msg: ${(error as BusinessError).message}`);
}
```
@@ -434,12 +434,11 @@ getAppVMMemoryInfo(): VMMemoryInfo
**示例:**
```ts
-import { hidebug, hilog } from '@kit.PerformanceAnalysisKit';
+import { hidebug } from '@kit.PerformanceAnalysisKit';
let vmMemory: hidebug.VMMemoryInfo = hidebug.getAppVMMemoryInfo();
-hilog.info(0x0000, "example", "totalHeap = %{public}d", vmMemory.totalHeap);
-hilog.info(0x0000, "example", "heapUsed = %{public}d", vmMemory.heapUsed);
-hilog.info(0x0000, "example", "allArraySize = %{public}d", vmMemory.allArraySize);
+console.info(`totalHeap = ${vmMemory.totalHeap}, heapUsed = ${vmMemory.heapUsed},` +
+ `allArraySize = ${vmMemory.allArraySize}` );
```
## hidebug.getAppThreadCpuUsage12+
@@ -461,12 +460,11 @@ getAppThreadCpuUsage(): ThreadCpuUsage[]
**示例:**
```ts
-import { hidebug, hilog } from '@kit.PerformanceAnalysisKit';
+import { hidebug } from '@kit.PerformanceAnalysisKit';
let appThreadCpuUsage: hidebug.ThreadCpuUsage[] = hidebug.getAppThreadCpuUsage();
for (let ii = 0; ii < appThreadCpuUsage.length; ii++) {
- hilog.info(0x0000, "example", "threadId=%{public}d, cpuUsage=%{public}f", appThreadCpuUsage[ii].threadId,
- appThreadCpuUsage[ii].cpuUsage);
+ console.info(`threadId=${appThreadCpuUsage[ii].threadId}, cpuUsage=${appThreadCpuUsage[ii].cpuUsage}`);
}
```
@@ -523,11 +521,16 @@ import { hidebug } from '@kit.PerformanceAnalysisKit';
let tags: number[] = [hidebug.tags.ABILITY_MANAGER, hidebug.tags.ARKUI];
let flag: hidebug.TraceFlag = hidebug.TraceFlag.MAIN_THREAD;
let limitSize: number = 1024 * 1024;
-let fileName: string = hidebug.startAppTraceCapture(tags, flag, limitSize);
-// code block
-// ...
-// code block
-hidebug.stopAppTraceCapture();
+
+try {
+ let fileName: string = hidebug.startAppTraceCapture(tags, flag, limitSize);
+ // code block
+ // ...
+ // code block
+ hidebug.stopAppTraceCapture();
+} catch (error) {
+ console.error(`error code: ${(error as BusinessError).code}, error msg: ${(error as BusinessError).message}`);
+}
```
## hidebug.stopAppTraceCapture12+
@@ -559,11 +562,15 @@ import { hidebug } from '@kit.PerformanceAnalysisKit';
let tags: number[] = [hidebug.tags.ABILITY_MANAGER, hidebug.tags.ARKUI];
let flag: hidebug.TraceFlag = hidebug.TraceFlag.MAIN_THREAD;
let limitSize: number = 1024 * 1024;
-let fileName: string = hidebug.startAppTraceCapture(tags, flag, limitSize);
-// code block
-// ...
-// code block
-hidebug.stopAppTraceCapture();
+try {
+ let fileName: string = hidebug.startAppTraceCapture(tags, flag, limitSize);
+ // code block
+ // ...
+ // code block
+ hidebug.stopAppTraceCapture();
+} catch (error) {
+ console.error(`error code: ${(error as BusinessError).code}, error msg: ${(error as BusinessError).message}`);
+}
```
## hidebug.getAppMemoryLimit12+
@@ -616,7 +623,11 @@ getSystemCpuUsage() : number
```ts
import { hidebug } from '@kit.PerformanceAnalysisKit';
-let cpuUsage: number = hidebug.getSystemCpuUsage();
+try {
+ console.info(`getSystemCpuUsage: ${hidebug.getSystemCpuUsage()}`)
+} catch (error) {
+ console.error(`error code: ${(error as BusinessError).code}, error msg: ${(error as BusinessError).message}`);
+}
```
## hidebug.setAppResourceLimit12+
@@ -655,7 +666,11 @@ import { hidebug } from '@kit.PerformanceAnalysisKit';
let type: string = 'js_heap';
let value: number = 85;
let enableDebugLog: boolean = false;
-hidebug.setAppResourceLimit(type, value, enableDebugLog);
+try {
+ hidebug.setAppResourceLimit(type, value, enableDebugLog);
+} catch (error) {
+ console.error(`error code: ${(error as BusinessError).code}, error msg: ${(error as BusinessError).message}`);
+}
```
## hidebug.getAppNativeMemInfo12+
@@ -675,23 +690,12 @@ getAppNativeMemInfo(): NativeMemInfo
**示例**
```ts
-import { hidebug, hilog } from '@kit.PerformanceAnalysisKit';
+import { hidebug } from '@kit.PerformanceAnalysisKit';
let nativeMemInfo: hidebug.NativeMemInfo = hidebug.getAppNativeMemInfo();
-
-hilog.info(0x0000, 'testTag', "pss = %{public}d", nativeMemInfo.pss);
-
-hilog.info(0x0000, 'testTag', "vss = %{public}d", nativeMemInfo.vss);
-
-hilog.info(0x0000, 'testTag', "rss = %{public}d", nativeMemInfo.rss);
-
-hilog.info(0x0000, 'testTag', "sharedDirty = %{public}d", nativeMemInfo.sharedDirty);
-
-hilog.info(0x0000, 'testTag', "privateDirty = %{public}d", nativeMemInfo.privateDirty);
-
-hilog.info(0x0000, 'testTag', "sharedClean = %{public}d", nativeMemInfo.sharedClean);
-
-hilog.info(0x0000, 'testTag', "privateClean = %{public}d", nativeMemInfo.privateClean);
+console.info(`pss: ${nativeMemInfo.pss}, vss: ${nativeMemInfo.vss}, rss: ${nativeMemInfo.rss}, ` +
+ `sharedDirty: ${nativeMemInfo.sharedDirty}, privateDirty: ${nativeMemInfo.privateDirty}, ` +
+ `sharedClean: ${nativeMemInfo.sharedClean}, privateClean: ${nativeMemInfo.privateClean}`);
```
## hidebug.getSystemMemInfo12+
@@ -711,15 +715,12 @@ getSystemMemInfo(): SystemMemInfo
**示例**
```ts
-import { hidebug, hilog } from '@kit.PerformanceAnalysisKit';
+import { hidebug } from '@kit.PerformanceAnalysisKit';
let systemMemInfo: hidebug.SystemMemInfo = hidebug.getSystemMemInfo();
-hilog.info(0x0000, 'testTag', "totalMem = %{public}d", systemMemInfo.totalMem);
-
-hilog.info(0x0000, 'testTag', "freeMem = %{public}d", systemMemInfo.freeMem);
-
-hilog.info(0x0000, 'testTag', "availableMem = %{public}d", systemMemInfo.availableMem);
+console.info(`totalMem: ${systemMemInfo.totalMem}, freeMem: ${systemMemInfo.freeMem}, ` +
+ `availableMem: ${systemMemInfo.availableMem}`);
```
## hidebug.getVMRuntimeStats12+
@@ -739,14 +740,14 @@ getVMRuntimeStats(): GcStats
**示例**
```ts
-import { hidebug, hilog } from '@kit.PerformanceAnalysisKit';
+import { hidebug } from '@kit.PerformanceAnalysisKit';
let vMRuntimeStats: hidebug.GcStats = hidebug.getVMRuntimeStats();
-hilog.info(0x0000, "testTag", `gc-count: ${vMRuntimeStats['ark.gc.gc-count']}`);
-hilog.info(0x0000, "testTag", `gc-time: ${vMRuntimeStats['ark.gc.gc-time']}`);
-hilog.info(0x0000, "testTag", `gc-bytes-allocated: ${vMRuntimeStats['ark.gc.gc-bytes-allocated']}`);
-hilog.info(0x0000, "testTag", `gc-bytes-freed: ${vMRuntimeStats['ark.gc.gc-bytes-freed']}`);
-hilog.info(0x0000, "testTag", `fullgc-longtime-count: ${vMRuntimeStats['ark.gc.fullgc-longtime-count']}`);
+console.info(`gc-count: ${vMRuntimeStats['ark.gc.gc-count']}`);
+console.info(`gc-time: ${vMRuntimeStats['ark.gc.gc-time']}`);
+console.info(`gc-bytes-allocated: ${vMRuntimeStats['ark.gc.gc-bytes-allocated']}`);
+console.info(`gc-bytes-freed: ${vMRuntimeStats['ark.gc.gc-bytes-freed']}`);
+console.info(`fullgc-longtime-count: ${vMRuntimeStats['ark.gc.fullgc-longtime-count']}`);
```
## hidebug.getVMRuntimeStat12+
@@ -780,13 +781,16 @@ getVMRuntimeStat(item : string): number
**示例**
```ts
-import { hidebug, hilog } from '@kit.PerformanceAnalysisKit';
-
-hilog.info(0x0000, "testTag", `gc-count: ${hidebug.getVMRuntimeStat('ark.gc.gc-count')}`);
-hilog.info(0x0000, "testTag", `gc-time: ${hidebug.getVMRuntimeStat('ark.gc.gc-time')}`);
-hilog.info(0x0000, "testTag", `gc-bytes-allocated: ${hidebug.getVMRuntimeStat('ark.gc.gc-bytes-allocated')}`);
-hilog.info(0x0000, "testTag", `gc-bytes-freed: ${hidebug.getVMRuntimeStat('ark.gc.gc-bytes-freed')}`);
-hilog.info(0x0000, "testTag", `fullgc-longtime-count: ${hidebug.getVMRuntimeStat('ark.gc.fullgc-longtime-count')}`);
+import { hidebug } from '@kit.PerformanceAnalysisKit';
+try {
+ console.info(`gc-count: ${hidebug.getVMRuntimeStat('ark.gc.gc-count')}`);
+ console.info(`gc-time: ${hidebug.getVMRuntimeStat('ark.gc.gc-time')}`);
+ console.info(`gc-bytes-allocated: ${hidebug.getVMRuntimeStat('ark.gc.gc-bytes-allocated')}`);
+ console.info(`gc-bytes-freed: ${hidebug.getVMRuntimeStat('ark.gc.gc-bytes-freed')}`);
+ console.info(`fullgc-longtime-count: ${hidebug.getVMRuntimeStat('ark.gc.fullgc-longtime-count')}`);
+} catch (error) {
+ console.error(`error code: ${(error as BusinessError).code}, error msg: ${(error as BusinessError).message}`);
+}
```
## MemoryLimit12+
@@ -944,7 +948,7 @@ isDebugState(): boolean
**示例**
```ts
-import { hidebug,hilog } from '@kit.PerformanceAnalysisKit';
+import { hidebug } from '@kit.PerformanceAnalysisKit';
-hilog.info(0x000, "testTag", "isDebugState = %{public}s", hidebug.isDebugState())
+console.info(`isDebugState = ${hidebug.isDebugState()}`)
```
\ No newline at end of file