提交 03f066f1 编写于 作者: W wenlong_12

arkts规范整改hidebug

Signed-off-by: Nwenlong_12 <wenlong12@huawei.com>
Change-Id: I911e669f77daa55dbc2adf7ab3c51d3997b74049
上级 295273c3
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
## 导入模块 ## 导入模块
```js ```ts
import hidebug from '@ohos.hidebug'; import hidebug from '@ohos.hidebug';
``` ```
...@@ -28,8 +28,8 @@ getNativeHeapSize(): bigint ...@@ -28,8 +28,8 @@ getNativeHeapSize(): bigint
| bigint | 返回本应用堆内存总大小,单位为kB。 | | bigint | 返回本应用堆内存总大小,单位为kB。 |
**示例:** **示例:**
```js ```ts
let nativeHeapSize = hidebug.getNativeHeapSize(); let nativeHeapSize : bigint = hidebug.getNativeHeapSize();
``` ```
## hidebug.getNativeHeapAllocatedSize ## hidebug.getNativeHeapAllocatedSize
...@@ -48,8 +48,8 @@ getNativeHeapAllocatedSize(): bigint ...@@ -48,8 +48,8 @@ getNativeHeapAllocatedSize(): bigint
**示例:** **示例:**
```js ```ts
let nativeHeapAllocatedSize = hidebug.getNativeHeapAllocatedSize(); let nativeHeapAllocatedSize : bigint = hidebug.getNativeHeapAllocatedSize();
``` ```
## hidebug.getNativeHeapFreeSize ## hidebug.getNativeHeapFreeSize
...@@ -67,8 +67,8 @@ getNativeHeapFreeSize(): bigint ...@@ -67,8 +67,8 @@ getNativeHeapFreeSize(): bigint
| bigint | 返回本应用堆内存的空闲内存,单位为kB。 | | bigint | 返回本应用堆内存的空闲内存,单位为kB。 |
**示例:** **示例:**
```js ```ts
let nativeHeapFreeSize = hidebug.getNativeHeapFreeSize(); let nativeHeapFreeSize : bigint = hidebug.getNativeHeapFreeSize();
``` ```
## hidebug.getPss ## hidebug.getPss
...@@ -86,8 +86,8 @@ getPss(): bigint ...@@ -86,8 +86,8 @@ getPss(): bigint
| bigint | 返回应用进程实际使用的物理内存大小,单位为kB。 | | bigint | 返回应用进程实际使用的物理内存大小,单位为kB。 |
**示例:** **示例:**
```js ```ts
let pss = hidebug.getPss(); let pss : bigint = hidebug.getPss();
``` ```
## hidebug.getSharedDirty ## hidebug.getSharedDirty
...@@ -106,8 +106,8 @@ getSharedDirty(): bigint ...@@ -106,8 +106,8 @@ getSharedDirty(): bigint
**示例:** **示例:**
```js ```ts
let sharedDirty = hidebug.getSharedDirty(); let sharedDirty : bigint = hidebug.getSharedDirty();
``` ```
## hidebug.getPrivateDirty<sup>9+<sup> ## hidebug.getPrivateDirty<sup>9+<sup>
...@@ -125,8 +125,8 @@ getPrivateDirty(): bigint ...@@ -125,8 +125,8 @@ getPrivateDirty(): bigint
| bigint | 返回进程的私有脏内存大小,单位为kB。 | | bigint | 返回进程的私有脏内存大小,单位为kB。 |
**示例:** **示例:**
```js ```ts
let privateDirty = hidebug.getPrivateDirty(); let privateDirty : bigint = hidebug.getPrivateDirty();
``` ```
## hidebug.getCpuUsage<sup>9+<sup> ## hidebug.getCpuUsage<sup>9+<sup>
...@@ -147,8 +147,8 @@ getCpuUsage(): number ...@@ -147,8 +147,8 @@ getCpuUsage(): number
**示例:** **示例:**
```js ```ts
let cpuUsage = hidebug.getCpuUsage(); let cpuUsage : number = hidebug.getCpuUsage();
``` ```
## hidebug.getServiceDump<sup>9+<sup> ## hidebug.getServiceDump<sup>9+<sup>
...@@ -172,31 +172,34 @@ getServiceDump(serviceid : number, fd : number, args : Array\<string>) : void ...@@ -172,31 +172,34 @@ getServiceDump(serviceid : number, fd : number, args : Array\<string>) : void
**示例:** **示例:**
```js ```ts
import fs from '@ohos.file.fs' import fs from '@ohos.file.fs'
import hidebug from '@ohos.hidebug' import hidebug from '@ohos.hidebug'
import common from '@ohos.app.ability.common' import common from '@ohos.app.ability.common'
import { BusinessError } from '@ohos.base'
let applicationContext: common.Context; let applicationContext: common.Context | null = null;
try { try {
applicationContext = this.context.getApplicationContext(); applicationContext = this.context.getApplicationContext();
} catch (error) { } catch (error) {
console.info(error.code); console.info((error as BusinessError).code);
console.info(error.message); console.info((error as BusinessError).message);
} }
var filesDir = applicationContext.filesDir; if (applicationContext) {
var path = filesDir + "/serviceInfo.txt"; let filesDir : string = applicationContext.filesDir;
}
let path : string = filesDir + "/serviceInfo.txt";
console.info("output path: " + path); console.info("output path: " + path);
let file = fs.openSync(path, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); let file : file.fs = fs.openSync(path, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
var serviceId = 10; let serviceId : number = 10;
var args = new Array("allInfo"); let args : Array = new Array("allInfo");
try { try {
hidebug.getServiceDump(serviceId, file.fd, args); hidebug.getServiceDump(serviceId, file.fd, args);
} catch (error) { } catch (error) {
console.info(error.code); console.info((error as BusinessError).code);
console.info(error.message); console.info((error as BusinessError).message);
} }
fs.closeSync(file); fs.closeSync(file);
``` ```
...@@ -217,16 +220,17 @@ startJsCpuProfiling(filename : string) : void ...@@ -217,16 +220,17 @@ startJsCpuProfiling(filename : string) : void
**示例:** **示例:**
```js ```ts
import hidebug from '@ohos.hidebug' import hidebug from '@ohos.hidebug'
import { BusinessError } from '@ohos.base'
try { try {
hidebug.startJsCpuProfiling("cpu_profiling"); hidebug.startJsCpuProfiling("cpu_profiling");
// ... // ...
hidebug.stopJsCpuProfiling(); hidebug.stopJsCpuProfiling();
} catch (error) { } catch (error) {
console.info(error.code) console.info((error as BusinessError).code)
console.info(error.message) console.info((error as BusinessError).message)
} }
``` ```
...@@ -246,16 +250,17 @@ stopJsCpuProfiling() : void ...@@ -246,16 +250,17 @@ stopJsCpuProfiling() : void
**示例:** **示例:**
```js ```ts
import hidebug from '@ohos.hidebug' import hidebug from '@ohos.hidebug'
import { BusinessError } from '@ohos.base'
try { try {
hidebug.startJsCpuProfiling("cpu_profiling"); hidebug.startJsCpuProfiling("cpu_profiling");
// ... // ...
hidebug.stopJsCpuProfiling(); hidebug.stopJsCpuProfiling();
} catch (error) { } catch (error) {
console.info(error.code) console.info((error as BusinessError).code)
console.info(error.message) console.info((error as BusinessError).message)
} }
``` ```
...@@ -275,14 +280,15 @@ dumpJsHeapData(filename : string) : void ...@@ -275,14 +280,15 @@ dumpJsHeapData(filename : string) : void
**示例:** **示例:**
```js ```ts
import hidebug from '@ohos.hidebug' import hidebug from '@ohos.hidebug'
import { BusinessError } from '@ohos.base'
try { try {
hidebug.dumpJsHeapData("heapData"); hidebug.dumpJsHeapData("heapData");
} catch (error) { } catch (error) {
console.info(error.code) console.info((error as BusinessError).code)
console.info(error.message) console.info((error as BusinessError).message)
} }
``` ```
...@@ -304,7 +310,7 @@ startProfiling(filename : string) : void ...@@ -304,7 +310,7 @@ startProfiling(filename : string) : void
**示例:** **示例:**
```js ```ts
hidebug.startProfiling("cpuprofiler-20220216"); hidebug.startProfiling("cpuprofiler-20220216");
// code block // code block
// ... // ...
...@@ -324,7 +330,7 @@ stopProfiling() : void ...@@ -324,7 +330,7 @@ stopProfiling() : void
**示例:** **示例:**
```js ```ts
hidebug.startProfiling("cpuprofiler-20220216"); hidebug.startProfiling("cpuprofiler-20220216");
// code block // code block
// ... // ...
...@@ -350,6 +356,6 @@ dumpHeapData(filename : string) : void ...@@ -350,6 +356,6 @@ dumpHeapData(filename : string) : void
**示例:** **示例:**
```js ```ts
hidebug.dumpHeapData("heap-20220216"); hidebug.dumpHeapData("heap-20220216");
``` ```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册