profiler-md 0.0.1 → 0.1.0
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/dist/cli.mjs +1646 -920
- package/dist/index.d.mts +91 -36
- package/dist/index.js +2 -2
- package/package.json +24 -12
- package/readme.md +31 -22
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "profiler-md",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Tomer Aberbach",
|
|
6
6
|
"email": "tomer@aberba.ch",
|
|
@@ -9,20 +9,29 @@
|
|
|
9
9
|
"description": "Converts performance profiles to human and LLM friendly Markdown.",
|
|
10
10
|
"keywords": [
|
|
11
11
|
"ai",
|
|
12
|
+
"bun",
|
|
13
|
+
"chrome",
|
|
12
14
|
"cli",
|
|
13
15
|
"cpu",
|
|
16
|
+
"deno",
|
|
14
17
|
"deopt",
|
|
15
18
|
"deoptimization",
|
|
19
|
+
"devtools",
|
|
16
20
|
"heap",
|
|
17
21
|
"llm",
|
|
18
22
|
"markdown",
|
|
19
23
|
"md",
|
|
24
|
+
"node",
|
|
20
25
|
"optimization",
|
|
21
26
|
"perf",
|
|
22
27
|
"performance",
|
|
28
|
+
"pretty",
|
|
23
29
|
"profile",
|
|
24
30
|
"profiler",
|
|
25
|
-
"
|
|
31
|
+
"snapshot",
|
|
32
|
+
"speedscope",
|
|
33
|
+
"timing",
|
|
34
|
+
"v8"
|
|
26
35
|
],
|
|
27
36
|
"homepage": "https://github.com/TomerAberbach/profiler-md",
|
|
28
37
|
"repository": "TomerAberbach/profiler-md",
|
|
@@ -55,6 +64,8 @@
|
|
|
55
64
|
"dependencies": {
|
|
56
65
|
"meow": "^14.1.0",
|
|
57
66
|
"picomatch": "^4.0.4",
|
|
67
|
+
"plur": "^6.0.0",
|
|
68
|
+
"pprof-format": "^2.2.1",
|
|
58
69
|
"pretty-bytes": "^7.1.0",
|
|
59
70
|
"pretty-ms": "^9.3.0"
|
|
60
71
|
},
|
|
@@ -64,25 +75,26 @@
|
|
|
64
75
|
"@tomer/eslint-config": "^5.0.0",
|
|
65
76
|
"@tomer/prettier-config": "^4.0.1",
|
|
66
77
|
"@types/picomatch": "^4.0.3",
|
|
67
|
-
"@vitest/coverage-v8": "^4.1.
|
|
78
|
+
"@vitest/coverage-v8": "^4.1.5",
|
|
68
79
|
"diff": "^9.0.0",
|
|
69
|
-
"eslint": "^10.2.
|
|
70
|
-
"jest-extended": "^7.0.0",
|
|
80
|
+
"eslint": "^10.2.1",
|
|
71
81
|
"jsdom": "^29.0.2",
|
|
72
|
-
"prettier": "^3.8.
|
|
82
|
+
"prettier": "^3.8.3",
|
|
73
83
|
"publint": "^0.3.18",
|
|
74
84
|
"rollup-plugin-tree-shakeable": "^2.0.0",
|
|
75
|
-
"tsdown": "^0.21.
|
|
76
|
-
"typescript": "^6.0.
|
|
77
|
-
"vitest": "^4.1.
|
|
85
|
+
"tsdown": "^0.21.10",
|
|
86
|
+
"typescript": "^6.0.3",
|
|
87
|
+
"vitest": "^4.1.5"
|
|
78
88
|
},
|
|
79
89
|
"scripts": {
|
|
80
|
-
"format": "prettier --cache --write
|
|
81
|
-
"
|
|
90
|
+
"format:base": "prettier --cache --write",
|
|
91
|
+
"format": "pnpm format:base .",
|
|
92
|
+
"lint:base": "eslint --cache --cache-location node_modules/.cache/eslint/ --fix",
|
|
93
|
+
"lint": "pnpm lint:base .",
|
|
82
94
|
"typecheck": "tsc --noEmit",
|
|
83
95
|
"test": "vitest",
|
|
84
96
|
"coverage": "vitest --coverage",
|
|
85
|
-
"bench": "
|
|
97
|
+
"bench": "./scripts/bench",
|
|
86
98
|
"build": "tsdown",
|
|
87
99
|
"update-readme": "node scripts/update-readme.ts",
|
|
88
100
|
"check-readme": "node scripts/update-readme.ts --check",
|
package/readme.md
CHANGED
|
@@ -53,17 +53,14 @@ $ profiler-md --help
|
|
|
53
53
|
Usage: profiler-md [options] [file]
|
|
54
54
|
|
|
55
55
|
Options:
|
|
56
|
-
-t, --type <type> Profile type
|
|
56
|
+
-t, --type <type> Profile type, auto-detected from content if omitted
|
|
57
|
+
[speedscope|v8-cpu-profile|v8-heap-profile|v8-heap-snapshot|pprof]
|
|
57
58
|
-o, --output <file> Output file (default: - for stdout)
|
|
58
59
|
--top-n <n> Number of top entries to show (default: 20)
|
|
59
60
|
--cwd <path> Working directory for relative file paths in output
|
|
60
|
-
--third-party <glob> Mark URLs matching this glob as third-party
|
|
61
|
+
--third-party <glob> Mark URLs matching this glob as third-party
|
|
62
|
+
(repeatable; default: node_modules)
|
|
61
63
|
--help Show this help message
|
|
62
|
-
|
|
63
|
-
Supported profile types:
|
|
64
|
-
*.cpuprofile -> v8-cpu-profile
|
|
65
|
-
*.heapprofile -> v8-heap-profile
|
|
66
|
-
*.heapsnapshot -> v8-heap-snapshot
|
|
67
64
|
```
|
|
68
65
|
|
|
69
66
|
<!-- CLI_HELP END -->
|
|
@@ -73,18 +70,27 @@ $ profiler-md --help
|
|
|
73
70
|
```js
|
|
74
71
|
import { readFile } from 'node:fs/promises'
|
|
75
72
|
import {
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
defaultIncludeEntry,
|
|
74
|
+
defaultIsThirdPartyEntry,
|
|
75
|
+
pprofToMd,
|
|
76
|
+
speedscopeProfileToMd,
|
|
78
77
|
v8CpuProfileToMd,
|
|
79
78
|
v8HeapProfileToMd,
|
|
79
|
+
v8HeapSnapshotToMd,
|
|
80
80
|
} from 'profiler-md'
|
|
81
81
|
|
|
82
|
-
const
|
|
83
|
-
const
|
|
82
|
+
const pprofData = await readFile(`example.pprof`)
|
|
83
|
+
const speedscopeProfileData = await readFile(`example.speedscope.json`)
|
|
84
|
+
const v8CpuProfileData = await readFile(`example.cpuprofile`)
|
|
85
|
+
const v8HeapProfileData = await readFile(`example.heapprofile`)
|
|
86
|
+
const v8HeapSnapshotData = await readFile(`example.heapsnapshot`)
|
|
84
87
|
|
|
85
88
|
// Basic usage
|
|
86
|
-
console.log(
|
|
87
|
-
console.log(
|
|
89
|
+
console.log(pprofToMd(pprofData))
|
|
90
|
+
console.log(speedscopeProfileToMd(speedscopeProfileData))
|
|
91
|
+
console.log(v8CpuProfileToMd(v8CpuProfileData))
|
|
92
|
+
console.log(v8HeapProfileToMd(v8HeapProfileData))
|
|
93
|
+
console.log(v8HeapSnapshotToMd(v8HeapSnapshotData))
|
|
88
94
|
|
|
89
95
|
// Complex usage
|
|
90
96
|
const options = {
|
|
@@ -92,17 +98,20 @@ const options = {
|
|
|
92
98
|
topN: 10,
|
|
93
99
|
// Make paths relative to a custom directory.
|
|
94
100
|
cwd: `/path/to/project`,
|
|
95
|
-
|
|
96
|
-
|
|
101
|
+
isThirdPartyEntry: entry =>
|
|
102
|
+
defaultIsThirdPartyEntry(entry) ||
|
|
97
103
|
// Treat an additional vendor directory as third-party.
|
|
98
|
-
url.pathname.includes(`/vendor/`),
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
// Exclude
|
|
102
|
-
|
|
104
|
+
!!entry.location?.url.pathname.includes(`/vendor/`),
|
|
105
|
+
includeEntry: entry =>
|
|
106
|
+
defaultIncludeEntry(entry) &&
|
|
107
|
+
// Exclude entries from a specific file.
|
|
108
|
+
!entry.location?.includes(`/path/to/project/src/noisy`),
|
|
103
109
|
}
|
|
104
|
-
console.log(
|
|
105
|
-
console.log(
|
|
110
|
+
console.log(pprofToMd(pprofData, options))
|
|
111
|
+
console.log(speedscopeProfileToMd(speedscopeProfileData, options))
|
|
112
|
+
console.log(v8CpuProfileToMd(v8CpuProfileData, options))
|
|
113
|
+
console.log(v8HeapProfileToMd(v8HeapProfileData, options))
|
|
114
|
+
console.log(v8HeapSnapshotToMd(v8HeapSnapshotData, options))
|
|
106
115
|
```
|
|
107
116
|
|
|
108
117
|
## Contributing
|