Retrieved article excerpt
Open article Β· Retrieved 2026-11-15T16:22:22.007808+00:00
[Markdown flame logo](https://github.com/TomerAberbach/profiler-md/blob/main/assets/logo.svg)
# profiler-md
[version](https://npmjs.org/package/profiler-md)
[CI](https://github.com/TomerAberbach/profiler-md/actions/workflows/ci.yml)
[Sponsor](https://github.com/sponsors/TomerAberbach)
Converts performance profiles to human and LLM friendly Markdown.
[Demo](https://github.com/TomerAberbach/profiler-md#demo) β’
[Features](https://github.com/TomerAberbach/profiler-md#features) β’
[Install](https://github.com/TomerAberbach/profiler-md#install) β’
[Usage](https://github.com/TomerAberbach/profiler-md#usage) β’
[Skill](https://github.com/TomerAberbach/profiler-md#skill) β’
[Languages and formats](https://github.com/TomerAberbach/profiler-md#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](https://github.com/TomerAberbach/profiler-md/issues/new).
## Demo
[Converting and diffing CPU profiles in the terminal](https://github.com/TomerAberbach/profiler-md/blob/main/assets/demo.gif)
```
# CPU profile
Took 2.52s over 2,563 samples (982.2Β΅s per sample).
| Category | % | Time | Samples |
| ------------------ | ----: | ------: | ------: |
| Third-party | 86.1% | 2.17s | 2,285 |
| Garbage collector | 7.5% | 187.7ms | 153 |
| Standard library | 4.8% | 120.0ms | 89 |
| Native | 1.5% | 36.6ms | 32 |
| Regular expression | 0.1% | 3.2ms | 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.29s (91.2%) (anonymous) at ./cpuprofile-run.mjs
β βββ 2.29s (90.8%) typeCheckProject at ./tsc-workload.mjs:3:33
β βββ β¦ 1.77s (70.4%) (anonymous) at ./node_modules/typescript/lib/typescript.js:123385:37
β β βββ β¦ 1.61s (64.1%) checkSourceFileWorker at ./node_modules/typescript/lib/typescript.js:87270:33
β β β βββ 1.61s (64.1%) 3 more callees, led by (32.5%) checkDeferredNodes at 87179:30
β β βββ β¦ 146.0ms (5.8%, self 0.8%) bind at ./node_modules/typescript/lib/typescript.js:46600:16
β β βββ 125.3ms (5.0%) 6 more callees, led by (3.1%) bindWorker at ./node_modules/typescript/lib/typescript.js:46663:22
β βββ 389.5ms (15.5%) createProgram at ./node_modules/typescript/lib/typescript.js:122262:23
β β βββ 389.5ms (15.5%) 7 more callees, led by (12.9%) forEach at 2365:17
β βββ β¦ 99.2ms (3.9%) (anonymous) at node:internal/modules/cjs/loader:1731:37
β βββ 86.5ms (3.4%) wrapSafe at 1671:18
β βββ 12.7ms (0.5%) (anonymous) at ./node_modules/typescript/lib/typescript.js:1:1 β¦
βββ 187.7ms (7.5%) (garbage collector)
βββ 35.1ms (1.4%) 24 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.5% | 187.7ms | 153 | `(garbage collector)` | `<unknown>` |
| 3.4% | 86.5ms | 69 | `wrapSafe` | `node:internal/modules/cjs/loader:1671:18` |
| 2.7% | 69.0ms | 65 | `recursiveTypeRelatedTo` | `./node_modules/typescript/lib/typescript.js:67063:36` |
| 1.9% | 48.8ms | 52 | `instantiateTypeWorker` | `./node_modules/typescript/lib/typescript.js:65023:33` |
| 1.5% | 38.9ms | 33 | `checkTypeRelatedTo` | `./node_modules/typescript/lib/typescript.js:66185:30` |
| 1.4% | 34.3ms | 43 | `isRelatedTo` | `./node_modules/typescript/lib/typescript.js:66493:25` |
| 1.2% | 29.6ms | 27 | `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](https://github.com/TomerAberbach/profiler-md/blob/main/examples/output/javascript.node.base.cpuprofile.md), or
[`examples/output/`](https://github.com/TomerAberbach/profiler-md/blob/main/examples/output) for heap snapshots and diffs.
## Features
- **Polyglot:**
[call stack profile, call graph, heap snapshot, and trace formats](https://github.com/TomerAberbach/profiler-md#languages-and-formats)
across many languages
- **Profile analysis:** rates, category breakdowns, and the hottest functions,
call stacks, lines, callers, and callees
- **Heap analysis:** self and
[dominator](https://en.wikipedia.org/wiki/Dominator_(graph_theory))-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 `all` JFR 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](https://github.com/TomerAberbach/profiler-md/blob/main/docs/api.md))
- **Self-documenting:** `--help <language>` and `--help <format>` explain how to
generate and read each format
- **Agent-ready:** ships a [skill](https://github.com/TomerAberbach/profiler-md#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,