Converts performance profiles to human and LLM friendly Markdown.
Demo โข Features โข Install โข Usage โข Skill โข Languages and formats
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, overriding $PROFILER_MD_LOG
(default: warn)
--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)
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/issuesAPI
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.
