TomerAberbach/profiler-md
Sobre
🔥 Converts performance profiles to human and LLM friendly Markdown.
IA e aprendizado de máquinaO que você pode fazer
- Polyglot: call stack profile, call graph, heap snapshot, and trace formats across many languages
- Profile analysis: rates, category breakdowns, and the hottest functions, call stacks, lines, callers, and callees
- Heap analysis: self and dominator-based retained sizes, retainer paths, and the largest constructors and strings
- Trace analysis: category and thread breakdowns, the longest spans with their attributes, nesting, and longest instances, the most frequent instants, and gauges such as heap size over time
Crescimento medido de estrelas
- em 24 h
- Coletando histórico
- em 7 dias
- Coletando histórico
- em 15 dias
- Coletando histórico
- em 1 mês
- Coletando histórico
Variações líquidas em períodos sobrepostos, não totais diários. Medições ausentes ficam em branco. Estrelas indicam interesse, não qualidade.
README.md
Originalprofiler-md
[!NOTE]
This package is in beta and I'm excited for you to try it! Share suggestions, bug reports, and feature requests by filing an issue.
Demo
# CPU profile
Took 2.52s over 1,984 samples (1.3ms per sample).
| Category | % | Time | Samples |
| ------------------ | ----: | ------: | ------: |
| Third-party | 86.0% | 2.17s | 1,707 |
| Garbage collector | 7.7% | 194.2ms | 153 |
| Standard library | 4.4% | 111.7ms | 88 |
| Native | 1.6% | 40.6ms | 32 |
| Regular expression | 0.2% | 3.8ms | 3 |
| Ours | 0.1% | 1.3ms | 1 |
Paths starting with `./` or `../` are relative to `/private/tmp/nix-shell.K1HXIc/profiler-md-input-generation.EdvtIc/zod/`.
`…` stands for omitted frames.
## Call tree
Call paths to the hottest functions.
```
├── 2.28s (90.7%) (anonymous) at ./cpuprofile-run.mjs
│ └── 2.28s (90.7%) typeCheckProject at ./tsc-workload.mjs:3:33
│ ├── … 1.77s (70.2%) (anonymous) at ./node_modules/typescript/lib/typescript.js:123385:37
│ │ ├── … 1.61s (63.8%) checkSourceFileWorker at ./node_modules/typescript/lib/typescript.js:87270:33
│ │ │ └── 1.61s (63.8%) 3 more callees, led by (32.8%) checkDeferredNodes at 87179:30
│ │ └── … 146.0ms (5.8%, self 1.1%) bind at ./node_modules/typescript/lib/typescript.js:46600:16
│ │ └── 119.3ms (4.7%) 6 more callees, led by (2.8%) bindWorker at ./node_modules/typescript/lib/typescript.js:46663:22
│ ├── 392.2ms (15.6%) createProgram at ./node_modules/typescript/lib/typescript.js:122262:23
│ │ └── 392.2ms (15.6%) 7 more callees, led by (13.0%) forEach at 2365:17
│ └── … 100.3ms (4.0%) (anonymous) at node:internal/modules/cjs/loader:1731:37
│ ├── 87.6ms (3.5%) wrapSafe at 1671:18
│ └── 12.7ms (0.5%) (anonymous) at ./node_modules/typescript/lib/typescript.js:1:1 …
├── 194.2ms (7.7%) (garbage collector)
└── 40.6ms (1.6%) 20 more root frames, led by (0.2%) recursiveTypeRelatedTo at ./node_modules/typescript/lib/typescript.js:67063:36
```
## Hottest functions
### Self time
Functions with the most time spent within the function body, excluding callees.
| % | Time | Samples | Function | Location |
| ---: | ------: | ------: | ---------------------------- | ------------------------------------------------------ |
| 7.7% | 194.2ms | 153 | `(garbage collector)` | `<unknown>` |
| 3.5% | 87.6ms | 69 | `wrapSafe` | `node:internal/modules/cjs/loader:1671:18` |
| 2.8% | 69.8ms | 55 | `recursiveTypeRelatedTo` | `./node_modules/typescript/lib/typescript.js:67063:36` |
| 2.1% | 53.3ms | 42 | `instantiateTypeWorker` | `./node_modules/typescript/lib/typescript.js:65023:33` |
| 1.5% | 38.1ms | 30 | `checkTypeRelatedTo` | `./node_modules/typescript/lib/typescript.js:66185:30` |
| 1.3% | 33.0ms | 26 | `isRelatedTo` | `./node_modules/typescript/lib/typescript.js:66493:25` |
| 1.2% | 29.2ms | 23 | `getObjectTypeInstantiation` | `./node_modules/typescript/lib/typescript.js:64785:38` |
…
The output continues with the hottest functions by total time, the hottest call
stacks, and per-line, caller, and callee detail. See the
full output, or
examples/output/ for heap snapshots and diffs.
Features
- Polyglot: call stack profile, call graph, heap snapshot, and trace formats across many languages
- Profile analysis: rates, category breakdowns, and the hottest functions, call stacks, lines, callers, and callees
- Heap analysis: self and dominator-based retained sizes, retainer paths, and the largest constructors and strings
- Trace analysis: category and thread breakdowns, the longest spans with their attributes, nesting, and longest instances, the most frequent instants, and gauges such as heap size over time
- Multi-profile inputs: one
allJFR recording becomes CPU, allocation, and lock contention profiles - Diffing: ranked regressions and improvements between two profiles, two heap snapshots, or two traces, across formats and profilers
- Source maps: resolves minified and transpiled locations back to original sources
- Zero config: auto-detects the format and profiler
- Configurable: top N, base URLs, categorization, filtering, and diff matching
- CLI and API: a command line and a fully-typed API with sync and async variants (API docs)
- Self-documenting:
--help <language>and--help <format>explain how to generate and read each format - Agent-ready: ships a skill that guides an agent through profiling and optimizing your code
Install
# npm
$ npm i -g profiler-md
# Homebrew
$ brew install tomeraberbach/tap/profiler-md
Shell completions (optional)
# Bash (Linux)
$ profiler-md --completion bash > ~/.local/share/bash-completion/completions/profiler-md
# Bash (macOS/Homebrew)
$ profiler-md --completion bash > $(brew --prefix)/etc/bash_completion.d/profiler-md
# Fish
$ profiler-md --completion fish > ~/.config/fish/completions/profiler-md.fish
# Zsh
$ profiler-md --completion zsh > ~/.zfunc/_profiler-md
# PowerShell
$ profiler-md --completion pwsh >> $PROFILE.CurrentUserCurrentHost
Usage
CLI
# Convert a profile, paged and syntax highlighted
$ profiler-md profile.cpuprofile
# Diff two profiles or two heap snapshots
$ profiler-md base.cpuprofile current.cpuprofile
# Write the Markdown to a file
$ profiler-md profile.pb.gz -o profile.md
# Read a profile from stdin
$ node --cpu-prof app.js && cat *.cpuprofile | profiler-md
# Show how to profile a language
$ profiler-md --help python
All flags
$ profiler-md --help
Converts performance profiles to human and LLM friendly Markdown.
Usage: profiler-md [OPTIONS] [FILE]
profiler-md [OPTIONS] BASE CURRENT
profiler-md --help [TOPIC]
Examples:
# Convert a profile, paged and syntax highlighted
$ profiler-md profile.cpuprofile
# Diff two profiles or two heap snapshots
$ profiler-md base.cpuprofile current.cpuprofile
# Write the Markdown to a file
$ profiler-md profile.pb.gz -o profile.md
# Read a profile from stdin
$ node --cpu-prof app.js && cat *.cpuprofile | profiler-md
# Show how to profile a language
$ profiler-md --help python
FILE Profile to convert (default: stdin)
BASE Base profile to diff
CURRENT Current profile to diff against the base
Output:
-o, --output FILE Output file (default: - for stdout)
--log-level LEVEL Verbosity of diagnostics printed to stderr
(default: warn) [env: PROFILER_MD_LOG]
--no-pager Disable stdout paging (default: auto)
--color, --no-color Enable or disable ANSI syntax highlighting
(default: auto)
Input:
-f, --format FORMAT Input profile format (default: auto)
-r, --origin ORIGIN Input profile origin (default: auto)
--source-maps GLOB Source maps (JSON or inline) to apply to
locations (repeatable)
--base-url STRING Base URL or path to show paths relative
to, or auto to infer one from the
program's own code (default: cwd)
Ranking:
--top-n N Entries to show per ranking, including
category subsections (default: 20)
--min-category-share FRACTION Share of the shown entries' self values a
category needs for its own subsection,
from 0 to 1 (default: 0.01)
Filtering:
--category REGEX=CATEGORY Categorize functions whose name or
location matches REGEX as CATEGORY, first
rule winning (repeatable)
--hide REGEX Hide entries whose name or location
matches REGEX, still counting hidden
entries in totals (repeatable)
--show REGEX Show only entries whose name or location
matches REGEX, still counting hidden
entries in totals (repeatable)
--hide-category CATEGORY Hide entries of CATEGORY, still counting
hidden entries in totals (repeatable)
--show-category CATEGORY Show only entries of CATEGORY, still
counting hidden entries in totals
(repeatable)
Diffing:
--match-name REGEX=REPLACEMENT Rewrite names matching REGEX to
REPLACEMENT when pairing diffed entries
(repeatable)
--match-location REGEX=REPLACEMENT Rewrite locations (URL, path, or logical
name) matching REGEX to REPLACEMENT when
pairing diffed entries (repeatable)
Help:
-h, --help [TOPIC] Show this help message or topic docs
--version Show the version
--completion SHELL Print a completion script for SHELL
(bash, fish, nu, pwsh, or zsh)
Log levels:
none, error, warn, info, debug
Formats:
callgrind, collapsed, ghc-eventlog, ghc-json-profile, hprof, jfr,
jsc-heap-snapshot, memray, perf, pprof, speedscope, systing, trace-event,
v8-cpu-profile, v8-heap-profile, v8-heap-snapshot, webkit-timeline-recording
Origins:
async-profiler, bun, chrome, clang, deno, dotnet-trace, eflambe, excimer, ghc,
go, gperftools, jdk, memray, nix, node, node-pprof, perf, pprof-jl, pprof-rs,
profile-jl, py-spy, pyinstrument, rbspy, safari, simpleperf, systing, tachyon,
tsc, unknown, valgrind
Function categories:
ours, third-party, stdlib, native, unknown, garbage-collector, compiler, jit,
regexp, kernel, idle
Heap snapshot categories:
object, array, string, concatenated-string, sliced-string, function, code,
regexp, number, big-number, symbol, native, object-shape, internal, synthetic,
unknown
Trace event categories:
script, parsing, compilation, garbage-collection-pause, garbage-collection,
style, layout, paint, io, other
Languages:
c/cpp, csharp/fsharp, elixir/erlang, fortran, go, haskell, java/kotlin/groovy,
javascript/typescript, julia, nix, php, python, ruby, rust, swift, zig
Docs: https://github.com/TomerAberbach/profiler-md
Bugs: https://github.com/TomerAberbach/profiler-md/issues
API
import { openAsBlob } from 'node:fs'
import { diffProfilesAsync, profileToMdAsync } from 'profiler-md'
// Convert a profile or heap snapshot. The format and origin are auto-detected
console.log(await profileToMdAsync(await openAsBlob(`example.cpuprofile`)))
// Diff two profiles or two heap snapshots
console.log(
await diffProfilesAsync(
await openAsBlob(`base.cpuprofile`),
await openAsBlob(`current.cpuprofile`),
),
)
See the API docs for sync variants, explicit formats and origins, and configuration callbacks.
Skill
Use the profile-optimize skill to have
an agent profile and optimize your code. The skill runs the profiler-md CLI,
so install it first.
Install the skill for any agent with skills:
$ npx skills add TomerAberbach/profiler-md --skill profile-optimize
Or install it natively:
Claude Code
$ claude plugin marketplace add TomerAberbach/profiler-md --sparse .claude-plugin
$ claude plugin install profiler-md@profiler-md
Pass --sparse .claude-plugin so Claude Code checks out only the marketplace
file instead of this repository's large example inputs. The plugin installs the
skill from the npm package. Invoke it as /profiler-md:profile-optimize.
Codex
$ codex plugin marketplace add TomerAberbach/profiler-md --sparse .claude-plugin
Then open /plugins, select the profiler-md marketplace, and install the
profiler-md plugin. Pass --sparse .claude-plugin so Codex checks out only
the marketplace file instead of this repository's large example inputs.
Pi
$ pi install npm:profiler-md
Fun fact: the skill has profiled and optimized profiler-md itself!
Languages and formats
Each language lists only the formats its own tools generate. Third-party tools convert others. Click a language for how to profile it, and a format for how to generate and read it.
Examples
Each example links to the Markdown for a base profile, a current profile, and the diff between them.
Browse 138 examples
| Language | Profile | Format | Markdown |
|---|---|---|---|
C/C++ | C Valgrind | Callgrind | base · current · diff |
| C perf CPU | perf.data | base · current · diff | |
| C simpleperf CPU | perf.data | base · current · diff | |
| C++ perf CPU | perf.data | base · current · diff | |
| C gperftools CPU | pprof | base · current · diff | |
| C gperftools heap | pprof | base · current · diff | |
| C++ gperftools CPU | pprof | base · current · diff | |
| C++ gperftools heap | pprof | base · current · diff | |
| C systing CPU | systing | base · current · diff | |
| C Clang | Trace Event Format | base · current · diff | |
| C++ Clang | Trace Event Format | base · current · diff | |
C#/F# | C# dotnet-trace | Speedscope | base · current · diff |
| F# dotnet-trace | Speedscope | base · current · diff | |
Elixir/Erlang | Elixir eflambe wall | Collapsed stacks | base · current · diff |
| Erlang eflambe wall | Collapsed stacks | base · current · diff | |
Fortran | gperftools CPU | pprof | base · current · diff |
| gperftools heap | pprof | base · current · diff | |
Go | pprof block | pprof | base · current · diff |
| pprof CPU | pprof | base · current · diff | |
| pprof CPU (-trimpath) | pprof | base · current · diff | |
| pprof goroutine | pprof | base · current · diff | |
| pprof goroutine leak | pprof | base · current · diff | |
| pprof heap | pprof | base · current · diff | |
| pprof heap-alloc | pprof | base · current · diff | |
| pprof mutex | pprof | base · current · diff | |
| pprof threadcreate | pprof | base · current · diff | |
Haskell | GHC | GHC eventlog | base · current · diff |
| GHC | GHC JSON profile | base · current · diff | |
Java/Kotlin/Groovy | Groovy async-profiler alloc | Collapsed stacks | base · current · diff |
| Groovy async-profiler alloc (dot) | Collapsed stacks | base · current · diff | |
| Groovy async-profiler CPU | Collapsed stacks | base · current · diff | |
| Groovy async-profiler CPU (dot) | Collapsed stacks | base · current · diff | |
| Groovy async-profiler CPU (threads, ann, sig) | Collapsed stacks | base · current · diff | |
| Java async-profiler alloc | Collapsed stacks | base · current · diff | |
| Java async-profiler alloc (dot) | Collapsed stacks | base · current · diff | |
| Java async-profiler CPU | Collapsed stacks | base · current · diff | |
| Java async-profiler CPU (dot) | Collapsed stacks | base · current · diff | |
| Java async-profiler CPU (threads, ann, sig) | Collapsed stacks | base · current · diff | |
| Kotlin async-profiler alloc | Collapsed stacks | base · current · diff | |
| Kotlin async-profiler alloc (dot) | Collapsed stacks | base · current · diff | |
| Kotlin async-profiler CPU | Collapsed stacks | base · current · diff | |
| Kotlin async-profiler CPU (dot) | Collapsed stacks | base · current · diff | |
| Kotlin async-profiler CPU (threads, ann, sig) | Collapsed stacks | base · current · diff | |
| Java JDK | HPROF | base · current · diff | |
| Groovy async-profiler all | JFR | base · current · diff | |
| Groovy async-profiler alloc | JFR | base · current · diff | |
| Groovy async-profiler CPU | JFR | base · current · diff | |
| Groovy async-profiler live | JFR | base · current · diff | |
| Groovy async-profiler lock | JFR | base · current · diff | |
| Groovy async-profiler nativemem | JFR | base · current · diff | |
| Groovy async-profiler wall | JFR | base · current · diff | |
| Groovy JDK all | JFR | base · current · diff | |
| Groovy JDK alloc | JFR | base · current · diff | |
| Groovy JDK CPU | JFR | base · current · diff | |
| Groovy JDK live | JFR | base · current · diff | |
| Groovy JDK lock | JFR | base · current · diff | |
| Java async-profiler all | JFR | base · current · diff | |
| Java async-profiler alloc | JFR | base · current · diff | |
| Java async-profiler CPU | JFR | base · current · diff | |
| Java async-profiler live | JFR | base · current · diff | |
| Java async-profiler lock | JFR | base · current · diff | |
| Java async-profiler nativemem | JFR | base · current · diff | |
| Java async-profiler wall | JFR | base · current · diff | |
| Java JDK all | JFR | base · current · diff | |
| Java JDK alloc | JFR | base · current · diff | |
| Java JDK CPU | JFR | base · current · diff | |
| Java JDK CPU (stackdepth=64) | JFR | base · current · diff | |
| Java JDK live | JFR | base · current · diff | |
| Java JDK lock | JFR | base · current · diff | |
| Kotlin async-profiler all | JFR | base · current · diff | |
| Kotlin async-profiler alloc | JFR | base · current · diff | |
| Kotlin async-profiler CPU | JFR | base · current · diff | |
| Kotlin async-profiler live | JFR | base · current · diff | |
| Kotlin async-profiler lock | JFR | base · current · diff | |
| Kotlin async-profiler nativemem | JFR | base · current · diff | |
| Kotlin async-profiler wall | JFR | base · current · diff | |
| Kotlin JDK all | JFR | base · current · diff | |
| Kotlin JDK alloc | JFR | base · current · diff | |
| Kotlin JDK CPU | JFR | base · current · diff | |
| Kotlin JDK live | JFR | base · current · diff | |
| Kotlin JDK lock | JFR | base · current · diff | |
JavaScript/TypeScript | JavaScript Bun | JSC heap snapshot | base · current · diff |
| JavaScript Safari | JSC heap snapshot | base · current · diff | |
| JavaScript node-pprof CPU | pprof | base · current · diff | |
| JavaScript node-pprof CPU (line numbers) | pprof | base · current · diff | |
| JavaScript node-pprof heap | pprof | base · current · diff | |
| JavaScript Node.js | Trace Event Format | base · current · diff | |
| TypeScript TypeScript compiler | Trace Event Format | base · current · diff | |
| JavaScript Bun | V8 CPU profile | base · current · diff | |
| JavaScript Chrome | V8 CPU profile | base · current · diff | |
| JavaScript Deno | V8 CPU profile | base · current · diff | |
| JavaScript Node.js | V8 CPU profile | base · current · diff | |
| JavaScript Chrome | V8 heap profile | base · current · diff | |
| JavaScript Node.js | V8 heap profile | base · current · diff | |
| JavaScript Node.js all allocations | V8 heap profile | base · current · diff | |
| JavaScript Bun | V8 heap snapshot | base · current · diff | |
| JavaScript Chrome | V8 heap snapshot | base · current · diff | |
| JavaScript Node.js | V8 heap snapshot | base · current · diff | |
| JavaScript Safari 17 | WebKit timeline recording | base · current · diff | |
| JavaScript Safari 26 | WebKit timeline recording | base · current · diff | |
Julia | pprof-jl alloc | pprof | base · current · diff |
| pprof-jl CPU | pprof | base · current · diff | |
| pprof-jl wall | pprof | base · current · diff | |
| Profile | V8 heap snapshot | base · current · diff | |
Nix | Nix | Collapsed stacks | base · current · diff |
PHP | Excimer wall | Collapsed stacks | base · current · diff |
| Excimer wall (max depth 16) | Collapsed stacks | base · current · diff | |
| Excimer wall | Speedscope | base · current · diff | |
| Excimer wall (max depth 16) | Speedscope | base · current · diff | |
Python | py-spy CPU | Collapsed stacks | base · current · diff |
| py-spy function | Collapsed stacks | base · current · diff | |
| py-spy native | Collapsed stacks | base · current · diff | |
| py-spy wall | Collapsed stacks | base · current · diff | |
| tachyon all threads | Collapsed stacks | base · current · diff | |
| tachyon CPU | Collapsed stacks | base · current · diff | |
| tachyon exception | Collapsed stacks | base · current · diff | |
| tachyon GIL | Collapsed stacks | base · current · diff | |
| tachyon native | Collapsed stacks | base · current · diff | |
| tachyon wall | Collapsed stacks | base · current · diff | |
| memray | memray | base · current · diff | |
| memray aggregated | memray | base · current · diff | |
| memray native | memray | base · current · diff | |
| memray Python 3.10 | memray | base · current · diff | |
| memray v13 | memray | base · current · diff | |
| py-spy CPU | Speedscope | base · current · diff | |
| py-spy function | Speedscope | base · current · diff | |
| py-spy native | Speedscope | base · current · diff | |
| pyinstrument | Speedscope | base · current · diff | |
Ruby | rbspy CPU | Callgrind | base · current · diff |
| rbspy CPU | Collapsed stacks | base · current · diff | |
| rbspy CPU | pprof | base · current · diff | |
| rbspy CPU | Speedscope | base · current · diff | |
Rust | pprof-rs CPU | pprof | base · current · diff |
Swift | gperftools CPU | pprof | base · current · diff |
| gperftools heap | pprof | base · current · diff | |
Zig | perf CPU | perf.data | base · current · diff |
| gperftools CPU | pprof | base · current · diff | |
| gperftools heap | pprof | base · current · diff |
Contributing
Stars are always welcome!
For bugs and feature requests, create an issue.
License
Explore projetos relacionados
Carregando…