profile-inspect
A fast CLI tool for analyzing V8 CPU and heap profiles from Node.js and Chrome DevTools.
Features
- Analyze
.cpuprofileand.heapprofilefiles - Compare two profiles to find performance regressions
- Focus on specific functions with caller/callee analysis
- Run commands with profiling enabled and get instant analysis
- Filter by category: app code, dependencies, Node.js internals, V8 internals
- Source map support for bundled code
- Multiple output formats: text, markdown, JSON, speedscope, collapsed stacks
Installation
From crates.io
From source
Pre-built binaries
Download from GitHub Releases.
Quick Start
# Analyze a CPU profile
# Run a command with profiling and instant analysis
# Compare two profiles
CLI Reference
profile-inspect cpu
Analyze a CPU profile file.
profile-inspect cpu [OPTIONS] <INPUT>
Arguments:
<INPUT>- Path to.cpuprofilefile
Options:
| Option | Description |
|---|---|
-f, --format <FORMAT> |
Output format: text, markdown, json, speedscope, collapsed (can specify multiple) |
-o, --output <DIR> |
Output directory for generated files |
--filter <CATEGORY> |
Filter by category: app, deps, node, v8, native |
--focus <PATTERN> |
Focus on functions matching regex pattern |
--exclude <PATTERN> |
Exclude functions matching regex pattern |
--package <NAME> |
Focus analysis on a specific npm package |
--sourcemap-dir <DIR> |
Directory containing source maps for bundled code |
--include-internals |
Include Node.js and V8 internal functions |
--min-percent <N> |
Only show functions with at least N% of total time |
--top <N> |
Show only top N functions |
Examples:
# Basic analysis with default text output
# Show only your app code, exclude dependencies
# Focus on parsing-related functions
# Exclude test files from analysis
# Analyze a specific package's performance
# Output as JSON and Markdown to a directory
# With source maps for bundled code
# Show functions taking at least 1% of time, top 50
# Include V8 and Node.js internals
profile-inspect heap
Analyze a heap profile file.
profile-inspect heap [OPTIONS] <INPUT>
Arguments:
<INPUT>- Path to.heapprofilefile
Options:
| Option | Description |
|---|---|
-f, --format <FORMAT> |
Output format (can specify multiple) |
-o, --output <DIR> |
Output directory |
--include-internals |
Include Node.js and V8 internals |
--min-percent <N> |
Minimum percentage to show |
--top <N> |
Maximum number of functions to show |
Examples:
# Basic heap analysis
# Show top 20 memory allocators
# Output as JSON
profile-inspect diff
Compare two CPU profiles to find performance changes.
profile-inspect diff [OPTIONS] <BEFORE> <AFTER>
Arguments:
<BEFORE>- Path to the "before" profile (baseline)<AFTER>- Path to the "after" profile (comparison)
Options:
| Option | Description |
|---|---|
--min-delta <N> |
Only show functions with at least N% change |
Examples:
# Compare two profiles
# Show only significant changes (>2%)
profile-inspect explain
Show callers and callees for a specific function.
profile-inspect explain --function <NAME> <INPUT>
Arguments:
<INPUT>- Path to profile file
Options:
| Option | Description |
|---|---|
--function <NAME> |
Function name to explain (required) |
Examples:
# Explain who calls processRequest and what it calls
# Works with partial matches
profile-inspect run
Run a command with profiling enabled and analyze the results.
profile-inspect run [OPTIONS] [CMD]...
Arguments:
[CMD]...- Command to run (specify after all flags)
Options:
| Option | Description |
|---|---|
--cpu |
Enable CPU profiling |
--heap |
Enable heap profiling |
-f, --format <FORMAT> |
Output format (can specify multiple) |
-o, --output <DIR> |
Output directory |
--filter <CATEGORY> |
Filter by category |
--package <NAME> |
Focus on a specific npm package |
--sourcemap-dir <DIR> |
Directory containing source maps |
--profile-dir <DIR> |
Save profile files to this directory (preserves them) |
--include-internals |
Include Node.js and V8 internals |
--min-percent <N> |
Minimum percentage to show |
--top <N> |
Maximum number of functions to show |
Examples:
# Run tests with CPU profiling
# Run with both CPU and heap profiling
# Profile and focus on a specific package
# Save profiles for later analysis
# Run with source map support
# Profile a complex command
Output Formats
| Format | Flag | Description |
|---|---|---|
| Text | -f text |
Human-readable terminal output (default) |
| Markdown | -f markdown |
Markdown tables for documentation |
| JSON | -f json |
Machine-readable JSON |
| Speedscope | -f speedscope |
Import into speedscope.app |
| Collapsed | -f collapsed |
Collapsed stack format for flame graphs |
You can specify multiple formats to generate all at once:
Categories
Functions are automatically classified into categories:
| Category | Flag | Description |
|---|---|---|
| App | --filter app |
Your application code |
| Deps | --filter deps |
Code from node_modules |
| Node | --filter node |
Node.js built-in modules |
| V8 | --filter v8 |
V8 JavaScript engine internals |
| Native | --filter native |
Native C++ addons |
Generating Profiles
Node.js CPU Profile
Node.js Heap Profile
Chrome DevTools
- Open DevTools (F12)
- Go to Performance tab
- Click Record, perform actions, stop recording
- Right-click on the profile and "Save profile..."
Development
# Setup development tools
# Run checks
# Run tests
# Build release
# Release a new version
License
MIT