Binggan

Binggan (餅乾, bǐng gān, means cookie in Chinese) is a benchmarking library for Rust. It is designed to be simple to use and to provide a good overview of the performance of your code and its memory consumption.
Features
- 📊 Peak Memory Usage
- 💎 Stack Offset Randomization
- 🔌 Plugin System
- 💖 Perf Integration (Linux)
- 🔄 Delta Comparison
- ⚡ BLAZINGLY Fast Execution
- 🔀 Interleaving Test Runs (More accurate results)
- 🏷️ Named Runs, Groups and Benchmarks
- 🧙 No Macros, No Magic (Just a regular API)
- 🦀 Runs on Stable Rust
- 📈 Custom Reporter
- 🧩 Report Output of Benchmarks
- 🎨 NOW with colored output!
- 🔍 Advanced Filtering (AND/OR/NOT and fields like
bench_name:my_bench)
Example
use ;
pub static GLOBAL: & = &INSTRUMENTED_SYSTEM;
Example Output
) )
) )
) )
) )
) )
) )
) )
) )
) )
) )
Peak Memory
To activate peak memory reporting, you need to wrap your allocator with the PeakMemAlloc and enable the PeakMemAllocPlugin (see example above).
While number of allocations are also interesting for performance analysis, peak memory will determine the memory requirements of the code.
Filtering
Binggan has a filtering system built in, powered by tantivy-query-grammar. You can run a subset of benchmarks by providing a query string to the CLI:
You can also use the BINGGAN_FILTER environment variable to set the filter:
BINGGAN_FILTER="my_bench OR other_bench"
Available fields are runner_name (or r), group_name (or g), and bench_name (or b). If no field is specified, it will match against the full generated BenchId.
Iteration overrides
If you want reproducible iteration counts without changing code, you can override them with environment variables:
NUM_ITER_BENCH=100
NUM_ITER_GROUP=16
NUM_ITER_GROUP=16 NUM_ITER_BENCH=100
NUM_ITER_BENCHsets the inner benchmark iteration count.NUM_ITER_GROUPsets how often the whole benchmark group is repeated.
Perf Integration
Perf may run into limitations where all counters are reported as zero. https://github.com/jimblandy/perf-event/issues/2 Disabling the NMI watchdog should help:
sudo sh -c "echo '0' > /proc/sys/kernel/nmi_watchdog"
TODO
- Improve the reporter api. Currently the reporter gets preaggregated data.
Maybe Later Features:
- Charts
- Auto comparison of Histograms (e.g. if a benchmark has several bands in which it operates, it would be nice to compare them)