The flamegraph export feature now supports generating standalone interactive HTML files in addition to raw SVG output. The interactive HTML format provides a rich user experience with hover tooltips, click-to-zoom, and search functionality—all without requiring external dependencies.
Enable profiling with the --profile flag:
erst debug --profile <transaction-hash>By default, this generates an interactive HTML file: <tx-hash>.flamegraph.html
Control the output format with the --profile-format flag:
# Interactive HTML (default)
erst debug --profile --profile-format html <transaction-hash>
# Raw SVG with dark mode support
erst debug --profile --profile-format svg <transaction-hash>The HTML export includes the following interactive capabilities:
- Hover over any frame to see detailed information
- Shows function name, file location, duration, and percentage
- Tooltips follow the mouse cursor
- Click any frame to zoom into that section of the flamegraph
- Provides better visibility for deeply nested call stacks
- Click "Reset Zoom" button to return to the full view
- Use the search box to find frames by name
- Matching frames are highlighted in magenta
- Case-insensitive search
- Click "Clear" to remove highlights
- Adapts to different viewport sizes
- Supports both light and dark color schemes
- Automatically detects system theme preference
The HTML export is completely self-contained:
- All CSS is inlined in a
<style>block - All JavaScript is inlined in a
<script>block - SVG is embedded directly in the HTML
- No external dependencies or network requests required
- Can be opened directly in any modern browser
Both SVG and HTML formats include CSS media queries that automatically adapt colors when the system is set to dark mode:
- Dark background (#1e1e2e)
- Light text (#cdd6f4)
- Adjusted frame colors for better contrast
The interactive HTML works in all modern browsers:
- Chrome/Edge 88+
- Firefox 78+
- Safari 14+
- Opera 74+
The implementation is located in internal/visualizer/flamegraph.go:
GenerateInteractiveHTML(svg string) string- Wraps SVG in interactive HTMLExportFlamegraph(svg string, format ExportFormat) string- Main export functionExportFormattype - Enum for format selection (HTML or SVG)GetFileExtension()- Returns appropriate file extension
The feature integrates with the existing --profile flag:
--profile- Enable profiling (defined ininternal/cmd/root.go)--profile-format- Choose export format:htmlorsvg(default:html)
Export logic is in internal/cmd/debug.go where the flamegraph is saved after simulation.
erst debug --profile abc123def456
# Output: abc123def456.flamegraph.htmlOpen the HTML file in your browser to explore the flamegraph interactively.
erst debug --profile --profile-format svg abc123def456
# Output: abc123def456.flamegraph.svgThe SVG can be opened in browsers or vector graphics editors.
erst debug --profile --network testnet --compare mainnet abc123def456
# Generates flamegraph for the primary network (testnet)Run the test suite to verify the implementation:
make test
# or
go test ./internal/visualizer/...To manually verify the HTML output:
- Run a debug command with profiling enabled
- Open the generated
.flamegraph.htmlfile in a browser - Verify the following:
- Flamegraph renders correctly
- Hover shows tooltips with frame details
- Click zooms into frames
- Reset button returns to full view
- Search finds and highlights frames
- Clear button removes highlights
- Dark mode adapts colors (toggle system theme)
- No console errors in browser DevTools
- No network requests (check Network tab)
The raw SVG export is still available via --profile-format svg. Existing workflows that expect SVG files can continue to use this format.
The default export format has changed from SVG to HTML. If you have scripts or automation that depend on SVG output, explicitly set --profile-format svg.
- HTML format:
.flamegraph.html - SVG format:
.flamegraph.svg
Both patterns are included in the default .gitignore generated by erst init.
Potential improvements for future versions:
- Export to other formats (PNG, PDF)
- Configurable color schemes
- Diff view for comparing two flamegraphs
- Flame chart view (time-based)
- Integration with profiling tools (pprof, perf)
- Keyboard shortcuts for navigation
- Permalink support for sharing specific views