Skip to main content
Synthesize trace events into a pprof-compliant profile that maps gas consumption to functions.

Usage

erst profile [trace-file] [flags]

Description

The profile command converts Erst execution traces into the pprof profile format, which can be analyzed using Go’s profiling tools. This allows you to:
  • Map gas consumption to specific functions
  • Identify performance bottlenecks
  • Analyze call graphs and hotspots
  • Generate flamegraphs with standard tooling
The output is compatible with go tool pprof and other pprof-compatible analyzers.

Examples

erst profile execution.json -o gas.pb.gz

Arguments

trace-file
string
Path to the trace file to convert (JSON format)Can be provided as positional argument or via --file flag.

Flags

--file
string
Trace file to load (alternative to positional argument)Alias: -f
--output
string
default:"profile.pb.gz"
Output pprof file pathAlias: -o

Output format

The generated profile file is a gzip-compressed protobuf that contains:
  • Sample data: Gas consumption per function call
  • Call stacks: Complete execution paths
  • Location info: Function names and contract addresses
  • Metadata: Transaction hash, network, and timestamps

Analyzing profiles

Once you’ve generated a profile, use these commands to analyze it:

Interactive web UI

go tool pprof -http=:8080 gas.pb.gz
This launches a web interface with:
  • Interactive flamegraph
  • Call graph visualization
  • Source code view (if debug symbols available)
  • Top functions by gas consumption

Command-line analysis

go tool pprof -top gas.pb.gz
Shows functions sorted by gas consumption.

Use cases

Optimize gas consumption

Identify which functions consume the most gas:
erst profile execution.json -o gas.pb.gz
go tool pprof -top10 gas.pb.gz

Compare optimizations

Generate profiles before and after optimization:
# Before
erst profile before.json -o before.pb.gz

# After
erst profile after.json -o after.pb.gz

# Compare
go tool pprof -base=before.pb.gz after.pb.gz

Debug performance issues

Find unexpected bottlenecks:
erst profile execution.json -o gas.pb.gz
go tool pprof -http=:8080 gas.pb.gz
# Click "Flame Graph" in web UI
  • trace - View traces interactively
  • debug - Generate traces from transactions
  • compare - Compare gas usage between versions