Skip to main content
The @flamedeck/import package provides a simple, unified API for importing performance profiles from various profiling tools and formats. It automatically detects the format and converts the data into the standard Speedscope format for analysis.

Installation

You can install the package using npm or yarn:

Basic Usage

The core of the library is the importProfile function that automatically handles format detection and Node.js dependency setup.

Simple Example

Binary Data Example

The package also handles binary profile formats:

Supported Formats

The package supports all the same formats as Speedscope:

Chrome DevTools

CPU Profiles (.cpuprofile), Timeline traces, Heap profiles

Firefox Profiler

Firefox profiler JSON format

pprof

Go, C++, Java profiles via pprof protocol buffers

Node.js

V8 profiler logs and CPU profiles

Safari

Safari Timeline recordings

Ruby

Stackprof JSON format

macOS Instruments

Deep copy text exports and trace directories

Linux Perf

Perf script output and collapsed stacks
Complete format list:
  • chrome-cpuprofile - Chrome DevTools CPU Profile
  • chrome-timeline - Chrome Timeline/Tracing format
  • chrome-heap-profile - Chrome Heap Profile
  • pprof - Protocol buffer format (Go, C++, etc.)
  • firefox - Firefox Profiler format
  • safari - Safari profiler format
  • stackprof - Ruby Stackprof format
  • instruments-deepcopy - macOS Instruments text export
  • instruments-trace - macOS Instruments trace directory
  • linux-perf - Linux perf script output
  • collapsed-stack - Collapsed stack format
  • v8-prof-log - V8 profiler log format
  • haskell - Haskell GHC profiler format
  • trace-event - Generic trace event format
  • callgrind - Valgrind Callgrind format
  • papyrus - Papyrus profiler format

API Reference

importProfile(input, fileName)

input
string | ArrayBuffer | Buffer
required
Profile data as string (for JSON formats), ArrayBuffer, or Node.js Buffer
fileName
string
required
The original filename (used for format detection)
Returns: Promise<ImportResult>

ImportResult

profileGroup
ProfileGroup | null
Contains the parsed profile data, or null if parsing failed
profileType
ProfileType
The detected profile format (e.g., ‘chrome-cpuprofile’, ‘pprof’, etc.)

ProfileGroup

When parsing succeeds, profileGroup contains:

Profile

Each profile provides comprehensive performance data:
getName()
() => string
Get the profile name
getTotalWeight()
() => number
Get total execution time/samples
getTotalNonIdleWeight()
() => number
Get total time excluding idle
getWeightUnit()
() => ValueUnit
Get time units (‘nanoseconds’, ‘milliseconds’, etc.)
formatValue(value)
(value: number) => string
Format a value with proper units
forEachFrame(fn)
(fn: (frame: Frame) => void) => void
Iterate over all frames in the profile
forEachCall(openFrame, closeFrame)
(openFrame, closeFrame) => void
Walk the call timeline in execution order
forEachCallGrouped(openFrame, closeFrame)
(openFrame, closeFrame) => void
Walk the grouped/sorted call tree (for flamegraph-like analysis)

Advanced Usage

Performance Analysis

Find the hottest functions in your profile:

Call Tree Analysis

Walk through the execution timeline:

Caller/Callee Analysis

Understand function relationships:

Flattening Recursion

Remove recursive calls for cleaner analysis:

Integration with FlameDeck

The @flamedeck/import package works seamlessly with other FlameDeck tools:
The import package is perfect for local analysis and preprocessing before uploading to FlameDeck for team collaboration.

Error Handling

Always wrap import calls in try-catch blocks:

TypeScript Support

The package includes full TypeScript definitions for all interfaces and classes, providing excellent IDE support and type safety for your profiling analysis code.