Rustbench
rustbench is a lightweight Rust procedural macro for benchmarking function execution time.
Installation
To use rustbench, add it to your Cargo.toml:
[]
= "0.1.1"
Then, add the macro as a procedural macro dependency:
[]
= true
Usage
Simply annotate any function with #[benchmark] to measure its execution time.
use benchmark;
Output
Function 'example_sum' executed in 7053000 ns
Iteration took: 11.716916ms
Iteration took: 10.26025ms
Iteration took: 9.13725ms
Iteration took: 8.560416ms
Iteration took: 7.905875ms
Function 'example_sum_iteration' executed 5 times. Avg time: 9516141 ns
Features (Planned)
- Comparison Mode: Compare execution time of two functions.
- Output Formats: JSON, CSV, or plain text.
- Memory Profiling: Measure memory usage during execution.
- Integration with Logging: Store benchmark results in logs.