@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 theimportProfile 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 profilesFirefox 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
chrome-cpuprofile- Chrome DevTools CPU Profilechrome-timeline- Chrome Timeline/Tracing formatchrome-heap-profile- Chrome Heap Profilepprof- Protocol buffer format (Go, C++, etc.)firefox- Firefox Profiler formatsafari- Safari profiler formatstackprof- Ruby Stackprof formatinstruments-deepcopy- macOS Instruments text exportinstruments-trace- macOS Instruments trace directorylinux-perf- Linux perf script outputcollapsed-stack- Collapsed stack formatv8-prof-log- V8 profiler log formathaskell- Haskell GHC profiler formattrace-event- Generic trace event formatcallgrind- Valgrind Callgrind formatpapyrus- Papyrus profiler format
API Reference
importProfile(input, fileName)
Profile data as string (for JSON formats), ArrayBuffer, or Node.js Buffer
The original filename (used for format detection)
Promise<ImportResult>
ImportResult
Contains the parsed profile data, or
null if parsing failedThe detected profile format (e.g., ‘chrome-cpuprofile’, ‘pprof’, etc.)
ProfileGroup
When parsing succeeds,profileGroup contains:
Profile
Each profile provides comprehensive performance data:Get the profile name
Get total execution time/samples
Get total time excluding idle
Get time units (‘nanoseconds’, ‘milliseconds’, etc.)
Format a value with proper units
Iterate over all frames in the profile
Walk the call timeline in execution order
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:

