Example project demonstrating performance profiling of Solana programs using Mollusk for testing and sbpf-profiler for flamegraph generation.
# Build the program
bun run programs:build
# Run tests
bun run programs:test
# Generate performance flamegraphs
bun run programs:profile- Mollusk provides a lightweight SVM environment for testing Solana programs
- SBPF Profiler captures performance data during program execution
- The profile script automatically generates flamegraphs for each instruction invocation, saving them with descriptive names like
test_hello_world_0_helloworld.svg
Flamegraphs are saved to the perf/ directory. Open the SVG files in a browser to explore the interactive performance profiles.
bun run programs:profile -- [test_name] # Profile specific test
bun run programs:profile -- -o benchmarks # Custom output directory
bun run programs:profile -- -h # Show all options- The program is built with the patched
solana-sbpf(seeCargo.toml) - Tests run with
SBPF_PROFILEenvironment variable enabled - Each instruction execution generates a flamegraph
- The script organizes outputs with meaningful names based on test and instruction