Benchmarking
Tools and techniques for measuring and optimizing gas consumption in CoW Protocol smart contracts.Benchmark Commands
Full Suite
Execute the complete benchmark suite across settlement scenarios:Execution Tracing
Generate detailed execution traces identifying gas consumption patterns:- Call stack hierarchy
- Per-operation gas consumption
- Storage operations
- External calls
- Event emission expenses
Version Comparison
Compare performance between code versions:- Stash current changes
- Benchmark current code
- Check out reference commit
- Benchmark reference code
- Generate differential report
- Positive values indicate regressions (increased gas)
- Negative values show improvements (decreased gas)
Single Scenario
Test individual settlement scenarios:Optimization Strategy
Follow a structured five-phase approach:- Establish baseline - Measure current gas consumption
- Identify hotspots - Use tracing to find expensive operations
- Implement improvements - Target specific gas-heavy operations
- Verify gains - Compare against baseline measurements
- Comprehensive testing - Ensure correctness is maintained
Compiler Configuration
The project compiler prioritizes execution costs:Best Practices
- Ensure clean builds without coverage instrumentation before benchmarking
- Use a stable environment (same machine, similar load)
- Run multiple iterations for consistent results
- Compare against known reference points
- Document significant performance changes