profiler-md 0.0.2 → 0.1.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/dist/cli.mjs +1296 -815
- package/dist/index.d.mts +95 -38
- package/dist/index.js +2 -2
- package/package.json +24 -12
- package/readme.md +51 -27
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "profiler-md",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
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
|
@@ -28,9 +28,15 @@
|
|
|
28
28
|
|
|
29
29
|
## Features
|
|
30
30
|
|
|
31
|
-
- **
|
|
31
|
+
- **Multi-format:** supports [pprof](https://github.com/google/pprof),
|
|
32
|
+
[Speedscope](https://github.com/jlfwong/speedscope),
|
|
33
|
+
[V8 CPU profiles](https://nodejs.org/api/cli.html#cpu-prof),
|
|
34
|
+
[V8 heap profiles](https://nodejs.org/api/cli.html#--heap-prof), and
|
|
35
|
+
[V8 heap snapshots](https://nodejs.org/api/cli.html#heapsnapshot-near-heap-limitmax-count)
|
|
36
|
+
- **Multi-language:** JS/TS via V8 formats (Node.js, Bun, Deno); Go, Python,
|
|
37
|
+
Rust, Java, and more via pprof and Speedscope
|
|
32
38
|
- **Configurable:** control the number of top entries shown, working directory
|
|
33
|
-
for relative paths,
|
|
39
|
+
for relative paths, third-party detection, and entry filtering
|
|
34
40
|
- **CLI and API:** usable on the command-line or programmatically
|
|
35
41
|
|
|
36
42
|
## Install
|
|
@@ -53,17 +59,14 @@ $ profiler-md --help
|
|
|
53
59
|
Usage: profiler-md [options] [file]
|
|
54
60
|
|
|
55
61
|
Options:
|
|
56
|
-
-t, --type <type> Profile type
|
|
62
|
+
-t, --type <type> Profile type, auto-detected from content if omitted
|
|
63
|
+
[pprof|speedscope|v8-cpu-profile|v8-heap-profile|v8-heap-snapshot]
|
|
57
64
|
-o, --output <file> Output file (default: - for stdout)
|
|
58
65
|
--top-n <n> Number of top entries to show (default: 20)
|
|
59
66
|
--cwd <path> Working directory for relative file paths in output
|
|
60
|
-
--third-party <glob> Mark URLs matching this glob as third-party
|
|
67
|
+
--third-party <glob> Mark URLs matching this glob as third-party
|
|
68
|
+
(repeatable; default: node_modules)
|
|
61
69
|
--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
70
|
```
|
|
68
71
|
|
|
69
72
|
<!-- CLI_HELP END -->
|
|
@@ -73,21 +76,27 @@ $ profiler-md --help
|
|
|
73
76
|
```js
|
|
74
77
|
import { readFile } from 'node:fs/promises'
|
|
75
78
|
import {
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
defaultIncludeEntry,
|
|
80
|
+
defaultIsThirdPartyEntry,
|
|
81
|
+
pprofToMd,
|
|
82
|
+
speedscopeProfileToMd,
|
|
78
83
|
v8CpuProfileToMd,
|
|
79
84
|
v8HeapProfileToMd,
|
|
80
85
|
v8HeapSnapshotToMd,
|
|
81
86
|
} from 'profiler-md'
|
|
82
87
|
|
|
83
|
-
const
|
|
84
|
-
const
|
|
85
|
-
const
|
|
88
|
+
const pprofData = await readFile(`example.pprof`)
|
|
89
|
+
const speedscopeProfileData = await readFile(`example.speedscope.json`)
|
|
90
|
+
const v8CpuProfileData = await readFile(`example.cpuprofile`)
|
|
91
|
+
const v8HeapProfileData = await readFile(`example.heapprofile`)
|
|
92
|
+
const v8HeapSnapshotData = await readFile(`example.heapsnapshot`)
|
|
86
93
|
|
|
87
94
|
// Basic usage
|
|
88
|
-
console.log(
|
|
89
|
-
console.log(
|
|
90
|
-
console.log(
|
|
95
|
+
console.log(pprofToMd(pprofData))
|
|
96
|
+
console.log(speedscopeProfileToMd(speedscopeProfileData))
|
|
97
|
+
console.log(v8CpuProfileToMd(v8CpuProfileData))
|
|
98
|
+
console.log(v8HeapProfileToMd(v8HeapProfileData))
|
|
99
|
+
console.log(v8HeapSnapshotToMd(v8HeapSnapshotData))
|
|
91
100
|
|
|
92
101
|
// Complex usage
|
|
93
102
|
const options = {
|
|
@@ -95,20 +104,35 @@ const options = {
|
|
|
95
104
|
topN: 10,
|
|
96
105
|
// Make paths relative to a custom directory.
|
|
97
106
|
cwd: `/path/to/project`,
|
|
98
|
-
|
|
99
|
-
|
|
107
|
+
isThirdPartyEntry: entry =>
|
|
108
|
+
defaultIsThirdPartyEntry(entry) ||
|
|
100
109
|
// Treat an additional vendor directory as third-party.
|
|
101
|
-
url.pathname.includes(`/vendor/`),
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
// Exclude
|
|
105
|
-
!
|
|
110
|
+
!!entry.location?.url.pathname.includes(`/vendor/`),
|
|
111
|
+
includeEntry: entry =>
|
|
112
|
+
defaultIncludeEntry(entry) &&
|
|
113
|
+
// Exclude entries from a specific file.
|
|
114
|
+
!entry.location?.includes(`/path/to/project/src/noisy`),
|
|
106
115
|
}
|
|
107
|
-
console.log(
|
|
108
|
-
console.log(
|
|
109
|
-
console.log(
|
|
116
|
+
console.log(pprofToMd(pprofData, options))
|
|
117
|
+
console.log(speedscopeProfileToMd(speedscopeProfileData, options))
|
|
118
|
+
console.log(v8CpuProfileToMd(v8CpuProfileData, options))
|
|
119
|
+
console.log(v8HeapProfileToMd(v8HeapProfileData, options))
|
|
120
|
+
console.log(v8HeapSnapshotToMd(v8HeapSnapshotData, options))
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Skills
|
|
124
|
+
|
|
125
|
+
Use this `profiler-md` skill to have an agent profile and optimize your code:
|
|
126
|
+
|
|
127
|
+
```sh
|
|
128
|
+
$ npx skills add TomerAberbach/profiler-md --skill profile-optimize
|
|
110
129
|
```
|
|
111
130
|
|
|
131
|
+
See [skills.sh](https://skills.sh/docs) for more info.
|
|
132
|
+
|
|
133
|
+
Fun fact: the skill has been used to profile and optimize `profiler-md` using
|
|
134
|
+
itself!
|
|
135
|
+
|
|
112
136
|
## Contributing
|
|
113
137
|
|
|
114
138
|
Stars are always welcome!
|