hiperf_txt_parser 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/parser.d.ts +4 -0
- package/dist/parser.js +8 -0
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -25,12 +25,14 @@ import {
|
|
|
25
25
|
parsePerfData,
|
|
26
26
|
formatPerfDataToText,
|
|
27
27
|
formatPerfDataToJson,
|
|
28
|
+
filterByTgid,
|
|
28
29
|
} from "hiperf_txt_parser";
|
|
29
30
|
```
|
|
30
31
|
|
|
31
32
|
- `parsePerfData(text: string): PerfData`
|
|
32
33
|
- `formatPerfDataToText(data: PerfData): string`
|
|
33
34
|
- `formatPerfDataToJson(data: PerfData): Array<{ issuce: "unknow"; call_chain: string }>`
|
|
35
|
+
- `filterByTgid(data: PerfData, tgid: number): PerfData`(仅保留 `pid === tgid` 的 RecordSample)
|
|
34
36
|
|
|
35
37
|
## 快速示例
|
|
36
38
|
|
|
@@ -40,7 +42,8 @@ import { parsePerfData, formatPerfDataToJson, formatPerfDataToText } from "hiper
|
|
|
40
42
|
const input = `record sample: type 9, misc 2, size 520\n sample_type: 0x8000107e7\n ID 13`;
|
|
41
43
|
|
|
42
44
|
const parsed = parsePerfData(input);
|
|
43
|
-
const
|
|
45
|
+
const filtered = filterByTgid(parsed, 1234);
|
|
46
|
+
const jsonArray = formatPerfDataToJson(filtered);
|
|
44
47
|
const txt = formatPerfDataToText(parsed);
|
|
45
48
|
```
|
|
46
49
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { parsePerfData } from "./parser.js";
|
|
1
|
+
export { parsePerfData, filterByTgid } from "./parser.js";
|
|
2
2
|
export { formatPerfDataToText, formatPerfDataToJson } from "./serializer.js";
|
|
3
3
|
export type { PerfData, RecordSample } from "./types.js";
|
|
4
4
|
export type { RecordSampleJsonExportItem } from "./serializer.js";
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { parsePerfData } from "./parser.js";
|
|
1
|
+
export { parsePerfData, filterByTgid } from "./parser.js";
|
|
2
2
|
export { formatPerfDataToText, formatPerfDataToJson } from "./serializer.js";
|
package/dist/parser.d.ts
CHANGED
|
@@ -3,3 +3,7 @@ import type { PerfData } from "./types.js";
|
|
|
3
3
|
* 解析 perf data 文本,仅返回 record sample 结构数组
|
|
4
4
|
*/
|
|
5
5
|
export declare function parsePerfData(text: string): PerfData;
|
|
6
|
+
/**
|
|
7
|
+
* 按 tgid 过滤 RecordSample(当前以 pid 字段作为 tgid)
|
|
8
|
+
*/
|
|
9
|
+
export declare function filterByTgid(data: PerfData, tgid: number): PerfData;
|
package/dist/parser.js
CHANGED
|
@@ -202,3 +202,11 @@ export function parsePerfData(text) {
|
|
|
202
202
|
}
|
|
203
203
|
return { recordSamples };
|
|
204
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* 按 tgid 过滤 RecordSample(当前以 pid 字段作为 tgid)
|
|
207
|
+
*/
|
|
208
|
+
export function filterByTgid(data, tgid) {
|
|
209
|
+
return {
|
|
210
|
+
recordSamples: data.recordSamples.filter((sample) => sample.pid === tgid),
|
|
211
|
+
};
|
|
212
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hiperf_txt_parser",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Parse perf data.txt and output structured TypeScript data",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -16,9 +16,14 @@
|
|
|
16
16
|
],
|
|
17
17
|
"scripts": {
|
|
18
18
|
"build": "tsc",
|
|
19
|
-
"
|
|
19
|
+
"prepublishOnly": "npm run build",
|
|
20
|
+
"test": "npm run build && node --test tests/filterByTgid.test.mjs"
|
|
20
21
|
},
|
|
21
|
-
"keywords": [
|
|
22
|
+
"keywords": [
|
|
23
|
+
"perf",
|
|
24
|
+
"parser",
|
|
25
|
+
"library"
|
|
26
|
+
],
|
|
22
27
|
"author": "",
|
|
23
28
|
"license": "MIT",
|
|
24
29
|
"devDependencies": {
|