Skip to main content
Flamegraphs visualize where your smart contract spends time and memory during execution. Erst generates interactive flamegraphs that help you identify performance bottlenecks and optimize contract efficiency.

Quick start

Generate an interactive flamegraph for any transaction:
This creates an interactive HTML file: <tx-hash>.flamegraph.html
By default, flamegraphs are exported as interactive HTML. Open the file in any modern browser to explore.

Export formats

Erst supports two flamegraph formats:

Format comparison

Interactive features

Hover tooltips

Move your mouse over any frame to see detailed information:
  • Function name
  • File location
  • Duration (microseconds)
  • Percentage of total time
  • Call depth

Click-to-zoom

Click any frame to zoom into that section of the flamegraph:
Zooming doesn’t change the data - it just filters the view. All percentages remain relative to the total execution time.

Search and highlight

Find specific functions quickly:

Responsive design

The interactive flamegraph adapts to:
  • Different viewport sizes (desktop, tablet, mobile)
  • Light and dark color schemes (automatic detection)
  • High-DPI displays

Understanding flamegraphs

Reading the visualization

Flamegraphs are read from bottom to top:
Key concepts:
  • Width: Represents time or memory consumed (wider = more resources)
  • Height: Call stack depth (higher = more nested calls)
  • Color: Different colors distinguish different functions (no semantic meaning)
  • Flat vs stacked: Flat frames are time spent in that function directly; stacked frames include children

Performance analysis

Use flamegraphs to identify:
Look for wide frames - these consume the most resources. If a frame spans most of the width, that function or its children are the bottleneck.Action: Focus optimization efforts on these wide functions.
Tall stacks indicate many nested function calls. Deep recursion or excessive abstraction layers can impact performance.Action: Consider flattening call hierarchies or using iterative approaches.
If you see the same function name repeated many times at the same level, that function is called multiple times in sequence.Action: Look for opportunities to batch operations or cache results.
Surprising functions appearing in hot paths may indicate:
  • Inefficient library usage
  • Unnecessary conversions or copies
  • Debug code left in release builds
Action: Review why these functions are called and if they can be avoided.

Common workflows

Profile a specific transaction

Compare network behavior

Profile the same transaction on different networks:
Open both files side-by-side to compare execution profiles.

Profile local WASM

Test contract performance during development:
Local WASM replay uses mock state, so performance characteristics may differ from on-chain execution.

Export for sharing

Dark mode support

Both HTML and SVG formats automatically adapt to your system’s color scheme: Light mode:
  • Light background (#ffffff)
  • Dark text (#000000)
  • Vibrant frame colors
Dark mode:
  • Dark background (#1e1e2e)
  • Light text (#cdd6f4)
  • Adjusted frame colors for contrast
No configuration needed - the flamegraph detects your system preference via CSS media queries.

Standalone files

HTML flamegraphs are completely self-contained:
  • All CSS inlined in <style> block
  • All JavaScript inlined in <script> block
  • SVG embedded directly
  • No external dependencies
  • No network requests
  • Works offline
You can:
  • Email the HTML file
  • Store it in version control
  • Host it on any web server
  • Open it directly from disk

Browser compatibility

Interactive HTML flamegraphs work in:
  • Chrome/Edge 88+
  • Firefox 78+
  • Safari 14+
  • Opera 74+
Older browsers may display the flamegraph but interactive features might not work.

Technical details

Implementation

Flamegraph generation is located in internal/visualizer/flamegraph.go:
  • GenerateInteractiveHTML() - Wraps SVG in interactive HTML
  • ExportFlamegraph() - Main export function
  • ExportFormat - Enum for format selection
  • GetFileExtension() - Returns appropriate extension

File extensions

  • HTML format: .flamegraph.html
  • SVG format: .flamegraph.svg
Both patterns are automatically added to .gitignore when running erst init.

Performance

Flamegraph generation is fast:
  • Small transactions (< 100 frames): < 50ms
  • Medium transactions (100-1000 frames): < 200ms
  • Large transactions (> 1000 frames): < 1s

Optimization tips

Reduce flamegraph complexity

If your flamegraph is too large to analyze:
  1. Filter by time threshold: Focus on frames taking > 1% of total time
  2. Zoom into hot paths: Use click-to-zoom to focus on expensive sections
  3. Search for specific functions: Use search to isolate particular concerns

Integrate with CI/CD

Automate performance regression detection:

Troubleshooting

Empty flamegraph

Solutions:
  • Ensure the transaction executed successfully
  • Check that your RPC supports diagnostic events
  • Try with --verbose to see what data is available

Flamegraph too small

If text is unreadable:
  • Use browser zoom (Ctrl/Cmd + +)
  • Click frames to zoom into specific sections
  • Export as SVG and open in a vector graphics editor

JavaScript errors in browser

Check browser console (F12) for errors:
  • Ensure you’re using a supported browser version
  • Try opening in a different browser
  • Verify the HTML file wasn’t corrupted during transfer

Next steps

Debugging failed transactions

Learn the fundamentals of transaction debugging

Working with sessions

Save profiling data for later analysis

Local WASM replay

Profile contracts during local development