Skip to content
프로젝트

소개

🔥 Converts performance profiles to human and LLM friendly Markdown.

AI 및 머신러닝

이 수치를 측정하는 방법

What you can do

  • 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

측정된 스타 증가

in 24h
기록 수집 중
in 7 days
기록 수집 중
in 15 days
기록 수집 중
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original
Markdown flame logo

profiler-md

Converts performance profiles to human and LLM friendly Markdown.

[!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

Converting and diffing CPU profiles in the terminal
# 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 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)
  • 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.


C C++
C⁠/⁠C++

Callgrind · perf.data · pprof · systing · Trace Event Format


C# F#
C#⁠/⁠F#

Speedscope


Elixir Erlang
Elixir⁠/⁠Erlang

Collapsed stacks


Fortran
Fortran

pprof


Go
Go

pprof


Haskell
Haskell

GHC eventlog · GHC JSON profile


Java Kotlin Groovy
Java⁠/⁠Kotlin⁠/⁠Groovy

Collapsed stacks · HPROF · JFR


JavaScript TypeScript
JavaScript⁠/⁠TypeScript

JSC heap snapshot · pprof · Trace Event Format · V8 CPU profile · V8 heap profile · V8 heap snapshot · WebKit timeline recording


Julia
Julia

pprof · V8 heap snapshot


Nix
Nix

Collapsed stacks


PHP
PHP

Collapsed stacks · Speedscope


Python
Python

Collapsed stacks · memray · Speedscope · systing


Ruby
Ruby

Callgrind · Collapsed stacks · pprof · Speedscope


Rust
Rust

pprof · systing


Swift
Swift

pprof


Zig
Zig

perf.data · pprof

Examples

Each example links to the Markdown for a base profile, a current profile, and the diff between them.

Browse 138 examples
LanguageProfileFormatMarkdown
C C++
C⁠/⁠C++
C ValgrindCallgrindbase · current · diff
C perf CPUperf.database · current · diff
C simpleperf CPUperf.database · current · diff
C++ perf CPUperf.database · current · diff
C gperftools CPUpprofbase · current · diff
C gperftools heappprofbase · current · diff
C++ gperftools CPUpprofbase · current · diff
C++ gperftools heappprofbase · current · diff
C systing CPUsystingbase · current · diff
C ClangTrace Event Formatbase · current · diff
C++ ClangTrace Event Formatbase · current · diff
C# F#
C#⁠/⁠F#
C# dotnet-traceSpeedscopebase · current · diff
F# dotnet-traceSpeedscopebase · current · diff
Elixir Erlang
Elixir⁠/⁠Erlang
Elixir eflambe wallCollapsed stacksbase · current · diff
Erlang eflambe wallCollapsed stacksbase · current · diff
Fortran
Fortran
gperftools CPUpprofbase · current · diff
gperftools heappprofbase · current · diff
Go
Go
pprof blockpprofbase · current · diff
pprof CPUpprofbase · current · diff
pprof CPU (-trimpath)pprofbase · current · diff
pprof goroutinepprofbase · current · diff
pprof goroutine leakpprofbase · current · diff
pprof heappprofbase · current · diff
pprof heap-allocpprofbase · current · diff
pprof mutexpprofbase · current · diff
pprof threadcreatepprofbase · current · diff
Haskell
Haskell
GHCGHC eventlogbase · current · diff
GHCGHC JSON profilebase · current · diff
Java Kotlin Groovy
Java⁠/⁠Kotlin⁠/⁠Groovy
Groovy async-profiler allocCollapsed stacksbase · current · diff
Groovy async-profiler alloc (dot)Collapsed stacksbase · current · diff
Groovy async-profiler CPUCollapsed stacksbase · current · diff
Groovy async-profiler CPU (dot)Collapsed stacksbase · current · diff
Groovy async-profiler CPU (threads, ann, sig)Collapsed stacksbase · current · diff
Java async-profiler allocCollapsed stacksbase · current · diff
Java async-profiler alloc (dot)Collapsed stacksbase · current · diff
Java async-profiler CPUCollapsed stacksbase · current · diff
Java async-profiler CPU (dot)Collapsed stacksbase · current · diff
Java async-profiler CPU (threads, ann, sig)Collapsed stacksbase · current · diff
Kotlin async-profiler allocCollapsed stacksbase · current · diff
Kotlin async-profiler alloc (dot)Collapsed stacksbase · current · diff
Kotlin async-profiler CPUCollapsed stacksbase · current · diff
Kotlin async-profiler CPU (dot)Collapsed stacksbase · current · diff
Kotlin async-profiler CPU (threads, ann, sig)Collapsed stacksbase · current · diff
Java JDKHPROFbase · current · diff
Groovy async-profiler allJFRbase · current · diff
Groovy async-profiler allocJFRbase · current · diff
Groovy async-profiler CPUJFRbase · current · diff
Groovy async-profiler liveJFRbase · current · diff
Groovy async-profiler lockJFRbase · current · diff
Groovy async-profiler nativememJFRbase · current · diff
Groovy async-profiler wallJFRbase · current · diff
Groovy JDK allJFRbase · current · diff
Groovy JDK allocJFRbase · current · diff
Groovy JDK CPUJFRbase · current · diff
Groovy JDK liveJFRbase · current · diff
Groovy JDK lockJFRbase · current · diff
Java async-profiler allJFRbase · current · diff
Java async-profiler allocJFRbase · current · diff
Java async-profiler CPUJFRbase · current · diff
Java async-profiler liveJFRbase · current · diff
Java async-profiler lockJFRbase · current · diff
Java async-profiler nativememJFRbase · current · diff
Java async-profiler wallJFRbase · current · diff
Java JDK allJFRbase · current · diff
Java JDK allocJFRbase · current · diff
Java JDK CPUJFRbase · current · diff
Java JDK CPU (stackdepth=64)JFRbase · current · diff
Java JDK liveJFRbase · current · diff
Java JDK lockJFRbase · current · diff
Kotlin async-profiler allJFRbase · current · diff
Kotlin async-profiler allocJFRbase · current · diff
Kotlin async-profiler CPUJFRbase · current · diff
Kotlin async-profiler liveJFRbase · current · diff
Kotlin async-profiler lockJFRbase · current · diff
Kotlin async-profiler nativememJFRbase · current · diff
Kotlin async-profiler wallJFRbase · current · diff
Kotlin JDK allJFRbase · current · diff
Kotlin JDK allocJFRbase · current · diff
Kotlin JDK CPUJFRbase · current · diff
Kotlin JDK liveJFRbase · current · diff
Kotlin JDK lockJFRbase · current · diff
JavaScript TypeScript
JavaScript⁠/⁠TypeScript
JavaScript BunJSC heap snapshotbase · current · diff
JavaScript SafariJSC heap snapshotbase · current · diff
JavaScript node-pprof CPUpprofbase · current · diff
JavaScript node-pprof CPU (line numbers)pprofbase · current · diff
JavaScript node-pprof heappprofbase · current · diff
JavaScript Node.jsTrace Event Formatbase · current · diff
TypeScript TypeScript compilerTrace Event Formatbase · current · diff
JavaScript BunV8 CPU profilebase · current · diff
JavaScript ChromeV8 CPU profilebase · current · diff
JavaScript DenoV8 CPU profilebase · current · diff
JavaScript Node.jsV8 CPU profilebase · current · diff
JavaScript ChromeV8 heap profilebase · current · diff
JavaScript Node.jsV8 heap profilebase · current · diff
JavaScript Node.js all allocationsV8 heap profilebase · current · diff
JavaScript BunV8 heap snapshotbase · current · diff
JavaScript ChromeV8 heap snapshotbase · current · diff
JavaScript Node.jsV8 heap snapshotbase · current · diff
JavaScript Safari 17WebKit timeline recordingbase · current · diff
JavaScript Safari 26WebKit timeline recordingbase · current · diff
Julia
Julia
pprof-jl allocpprofbase · current · diff
pprof-jl CPUpprofbase · current · diff
pprof-jl wallpprofbase · current · diff
ProfileV8 heap snapshotbase · current · diff
Nix
Nix
NixCollapsed stacksbase · current · diff
PHP
PHP
Excimer wallCollapsed stacksbase · current · diff
Excimer wall (max depth 16)Collapsed stacksbase · current · diff
Excimer wallSpeedscopebase · current · diff
Excimer wall (max depth 16)Speedscopebase · current · diff
Python
Python
py-spy CPUCollapsed stacksbase · current · diff
py-spy functionCollapsed stacksbase · current · diff
py-spy nativeCollapsed stacksbase · current · diff
py-spy wallCollapsed stacksbase · current · diff
tachyon all threadsCollapsed stacksbase · current · diff
tachyon CPUCollapsed stacksbase · current · diff
tachyon exceptionCollapsed stacksbase · current · diff
tachyon GILCollapsed stacksbase · current · diff
tachyon nativeCollapsed stacksbase · current · diff
tachyon wallCollapsed stacksbase · current · diff
memraymemraybase · current · diff
memray aggregatedmemraybase · current · diff
memray nativememraybase · current · diff
memray Python 3.10memraybase · current · diff
memray v13memraybase · current · diff
py-spy CPUSpeedscopebase · current · diff
py-spy functionSpeedscopebase · current · diff
py-spy nativeSpeedscopebase · current · diff
pyinstrumentSpeedscopebase · current · diff
Ruby
Ruby
rbspy CPUCallgrindbase · current · diff
rbspy CPUCollapsed stacksbase · current · diff
rbspy CPUpprofbase · current · diff
rbspy CPUSpeedscopebase · current · diff
Rust
Rust
pprof-rs CPUpprofbase · current · diff
Swift
Swift
gperftools CPUpprofbase · current · diff
gperftools heappprofbase · current · diff
Zig
Zig
perf CPUperf.database · current · diff
gperftools CPUpprofbase · current · diff
gperftools heappprofbase · current · diff

Contributing

Stars are always welcome!

For bugs and feature requests, create an issue.

License

MIT © Tomer Aberbach

관련 프로젝트 살펴보기

불러오는 중…