profiler-md 0.0.2 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "profiler-md",
3
- "version": "0.0.2",
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
- "timing"
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.3",
78
+ "@vitest/coverage-v8": "^4.1.5",
68
79
  "diff": "^9.0.0",
69
- "eslint": "^10.2.0",
70
- "jest-extended": "^7.0.0",
80
+ "eslint": "^10.2.1",
71
81
  "jsdom": "^29.0.2",
72
- "prettier": "^3.8.1",
82
+ "prettier": "^3.8.3",
73
83
  "publint": "^0.3.18",
74
84
  "rollup-plugin-tree-shakeable": "^2.0.0",
75
- "tsdown": "^0.21.7",
76
- "typescript": "^6.0.2",
77
- "vitest": "^4.1.3"
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
- "lint": "eslint --cache --cache-location node_modules/.cache/eslint/ --fix .",
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": "vitest 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 (auto-detected from file extension by default)
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 (repeatable; default: node_modules)
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,21 +70,27 @@ $ profiler-md --help
73
70
  ```js
74
71
  import { readFile } from 'node:fs/promises'
75
72
  import {
76
- defaultIncludeRow,
77
- defaultIsThirdPartyURL,
73
+ defaultIncludeEntry,
74
+ defaultIsThirdPartyEntry,
75
+ pprofToMd,
76
+ speedscopeProfileToMd,
78
77
  v8CpuProfileToMd,
79
78
  v8HeapProfileToMd,
80
79
  v8HeapSnapshotToMd,
81
80
  } from 'profiler-md'
82
81
 
83
- const cpuProfileData = await readFile(`example.cpuprofile`)
84
- const heapProfileData = await readFile(`example.heapprofile`)
85
- const heapSnapshotData = await readFile(`example.heapsnapshot`)
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`)
86
87
 
87
88
  // Basic usage
88
- console.log(v8CpuProfileToMd(cpuProfileData))
89
- console.log(v8HeapProfileToMd(heapProfileData))
90
- console.log(v8HeapSnapshotToMd(heapSnapshotData))
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))
91
94
 
92
95
  // Complex usage
93
96
  const options = {
@@ -95,18 +98,20 @@ const options = {
95
98
  topN: 10,
96
99
  // Make paths relative to a custom directory.
97
100
  cwd: `/path/to/project`,
98
- isThirdPartyURL: url =>
99
- defaultIsThirdPartyURL(url) ||
101
+ isThirdPartyEntry: entry =>
102
+ defaultIsThirdPartyEntry(entry) ||
100
103
  // Treat an additional vendor directory as third-party.
101
- url.pathname.includes(`/vendor/`),
102
- includeRow: row =>
103
- defaultIncludeRow(row) &&
104
- // Exclude rows from a specific file.
105
- !row.location?.includes(`/path/to/project/src/noisy.js`),
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`),
106
109
  }
107
- console.log(v8CpuProfileToMd(cpuProfileData, options))
108
- console.log(v8HeapProfileToMd(heapProfileData, options))
109
- console.log(v8HeapSnapshotToMd(heapSnapshotData, options))
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))
110
115
  ```
111
116
 
112
117
  ## Contributing