profiler-md 0.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/package.json ADDED
@@ -0,0 +1,92 @@
1
+ {
2
+ "name": "profiler-md",
3
+ "version": "0.0.1",
4
+ "author": {
5
+ "name": "Tomer Aberbach",
6
+ "email": "tomer@aberba.ch",
7
+ "url": "https://tomeraberba.ch"
8
+ },
9
+ "description": "Converts performance profiles to human and LLM friendly Markdown.",
10
+ "keywords": [
11
+ "ai",
12
+ "cli",
13
+ "cpu",
14
+ "deopt",
15
+ "deoptimization",
16
+ "heap",
17
+ "llm",
18
+ "markdown",
19
+ "md",
20
+ "optimization",
21
+ "perf",
22
+ "performance",
23
+ "profile",
24
+ "profiler",
25
+ "timing"
26
+ ],
27
+ "homepage": "https://github.com/TomerAberbach/profiler-md",
28
+ "repository": "TomerAberbach/profiler-md",
29
+ "bugs": {
30
+ "url": "https://github.com/TomerAberbach/profiler-md/issues"
31
+ },
32
+ "funding": {
33
+ "url": "https://github.com/sponsors/TomerAberbach"
34
+ },
35
+ "license": "MIT",
36
+ "files": [
37
+ "dist"
38
+ ],
39
+ "type": "module",
40
+ "sideEffects": false,
41
+ "engines": {
42
+ "node": ">= 22"
43
+ },
44
+ "bin": {
45
+ "profiler-md": "./dist/cli.mjs"
46
+ },
47
+ "exports": {
48
+ ".": {
49
+ "types": "./dist/index.d.mts",
50
+ "default": "./dist/index.js"
51
+ },
52
+ "./package.json": "./package.json"
53
+ },
54
+ "prettier": "@tomer/prettier-config",
55
+ "dependencies": {
56
+ "meow": "^14.1.0",
57
+ "picomatch": "^4.0.4",
58
+ "pretty-bytes": "^7.1.0",
59
+ "pretty-ms": "^9.3.0"
60
+ },
61
+ "devDependencies": {
62
+ "@fast-check/vitest": "^0.4.0",
63
+ "@rollup/plugin-terser": "^1.0.0",
64
+ "@tomer/eslint-config": "^5.0.0",
65
+ "@tomer/prettier-config": "^4.0.1",
66
+ "@types/picomatch": "^4.0.3",
67
+ "@vitest/coverage-v8": "^4.1.3",
68
+ "diff": "^9.0.0",
69
+ "eslint": "^10.2.0",
70
+ "jest-extended": "^7.0.0",
71
+ "jsdom": "^29.0.2",
72
+ "prettier": "^3.8.1",
73
+ "publint": "^0.3.18",
74
+ "rollup-plugin-tree-shakeable": "^2.0.0",
75
+ "tsdown": "^0.21.7",
76
+ "typescript": "^6.0.2",
77
+ "vitest": "^4.1.3"
78
+ },
79
+ "scripts": {
80
+ "format": "prettier --cache --write .",
81
+ "lint": "eslint --cache --cache-location node_modules/.cache/eslint/ --fix .",
82
+ "typecheck": "tsc --noEmit",
83
+ "test": "vitest",
84
+ "coverage": "vitest --coverage",
85
+ "bench": "vitest bench",
86
+ "build": "tsdown",
87
+ "update-readme": "node scripts/update-readme.ts",
88
+ "check-readme": "node scripts/update-readme.ts --check",
89
+ "update-examples": "node scripts/update-examples.ts",
90
+ "check-examples": "node scripts/update-examples.ts --check"
91
+ }
92
+ }
package/readme.md ADDED
@@ -0,0 +1,118 @@
1
+ <h1 align="center">
2
+ profiler-md
3
+ </h1>
4
+
5
+ <div align="center">
6
+ <a href="https://npmjs.org/package/profiler-md">
7
+ <img src="https://badgen.net/npm/v/profiler-md" alt="version" />
8
+ </a>
9
+ <a href="https://github.com/TomerAberbach/profiler-md/actions">
10
+ <img src="https://github.com/TomerAberbach/profiler-md/workflows/CI/badge.svg" alt="CI" />
11
+ </a>
12
+ <a href="https://github.com/sponsors/TomerAberbach">
13
+ <img src="https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub&color=%23fe8e86" alt="Sponsor" />
14
+ </a>
15
+ </div>
16
+
17
+ <div align="center">
18
+ Converts performance profiles to human and LLM friendly Markdown.
19
+ </div>
20
+
21
+ > [!NOTE]
22
+ >
23
+ > This package is in a **beta** state and I'm excited for you to try it out!
24
+ >
25
+ > I'd love your feedback! Share any suggestions, bug reports, feature requests,
26
+ > or general thoughts by
27
+ > [filing an issue](https://github.com/TomerAberbach/profiler-md/issues/new).
28
+
29
+ ## Features
30
+
31
+ - **Auto-detection:** infers profile type automatically
32
+ - **Configurable:** control the number of top entries shown, working directory
33
+ for relative paths, and third-party URL detection
34
+ - **CLI and API:** usable on the command-line or programmatically
35
+
36
+ ## Install
37
+
38
+ ```sh
39
+ $ npm i profiler-md
40
+ ```
41
+
42
+ ## Usage
43
+
44
+ ### CLI
45
+
46
+ <!-- CLI_HELP START -->
47
+
48
+ ```sh
49
+ $ profiler-md --help
50
+
51
+ Converts performance profiles to human and LLM friendly Markdown.
52
+
53
+ Usage: profiler-md [options] [file]
54
+
55
+ Options:
56
+ -t, --type <type> Profile type (auto-detected from file extension by default)
57
+ -o, --output <file> Output file (default: - for stdout)
58
+ --top-n <n> Number of top entries to show (default: 20)
59
+ --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
+ --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
+ ```
68
+
69
+ <!-- CLI_HELP END -->
70
+
71
+ ### API
72
+
73
+ ```js
74
+ import { readFile } from 'node:fs/promises'
75
+ import {
76
+ defaultIncludeCallFrame,
77
+ defaultIsThirdPartyURL,
78
+ v8CpuProfileToMd,
79
+ v8HeapProfileToMd,
80
+ } from 'profiler-md'
81
+
82
+ const cpuText = await readFile(`profile.cpuprofile`)
83
+ const heapText = await readFile(`profile.heapprofile`)
84
+
85
+ // Basic usage
86
+ console.log(v8CpuProfileToMd(cpuText))
87
+ console.log(v8HeapProfileToMd(heapText))
88
+
89
+ // Complex usage
90
+ const options = {
91
+ // Show top 10 functions instead of the default 20.
92
+ topN: 10,
93
+ // Make paths relative to a custom directory.
94
+ cwd: `/path/to/project`,
95
+ isThirdPartyURL: url =>
96
+ defaultIsThirdPartyURL(url) ||
97
+ // Treat an additional vendor directory as third-party.
98
+ url.pathname.includes(`/vendor/`),
99
+ includeCallFrame: callFrame =>
100
+ defaultIncludeCallFrame(callFrame) &&
101
+ // Exclude frames from a specific file.
102
+ callFrame.url?.pathname !== `/path/to/project/src/noisy.js`,
103
+ }
104
+ console.log(v8CpuProfileToMd(cpuText, options))
105
+ console.log(v8HeapProfileToMd(heapText, options))
106
+ ```
107
+
108
+ ## Contributing
109
+
110
+ Stars are always welcome!
111
+
112
+ For bugs and feature requests,
113
+ [please create an issue](https://github.com/TomerAberbach/profiler-md/issues/new).
114
+
115
+ ## License
116
+
117
+ [MIT](https://github.com/TomerAberbach/profiler-md/blob/main/license) ©
118
+ [Tomer Aberbach](https://github.com/TomerAberbach)