| Crates.io | benchman |
| lib.rs | benchman |
| version | 0.2.6 |
| created_at | 2021-12-16 08:15:35.643053+00 |
| updated_at | 2021-12-19 05:52:47.188698+00 |
| description | A benchmark tool that focuses on one-shot benchmark |
| homepage | |
| repository | https://github.com/akiradeveloper/benchman |
| max_upload_size | |
| id | 499060 |
| size | 11,258 |
I guess there are two types of benchmarks.
One is a benchmark of a small and fast function in which we want the statistics from a million of iterations. For this type of benchmark, Criterion.rs is a good fit.
Another type is what I call one-shot benchmark.
You may have wanted to write a benchmark program like this.
let mut db = DB::new();
let t = Instant::now();
db.write(...);
println!("write: {:?}", t.elapsed());
let t = Instant::now();
db.read(...);
println!("read: {:?}", t.elapsed());
According to Criterion.rs #531, this type of benchmark is infeasible with Criterion.rs because Criterion is focusing on the first type.
That's why I started to create benchman.
RAII is a good technique to manage resource access. My idea behind designing benchman is that stopwatch is like a resource because it is like a producer of a benchmark result that sends the result to the single central consumer and there is a strict rule that stopwatch shouldn't send the result twice.
With this idea, the library is designed like this.
let stopwatch = benchman.get_stopwatch("some_tag");
do_something();
drop(stopwatch);
// or
{
let _sw = benchman.get_stopwatch("some_tag");
do_something();
}
When the stopwatch is dropped, the measurement result is sent to the central database.

Akira Hayakawa (@akiradeveloper)