Add zid stringify bench test

Signed-off-by: Dhammika Pathirana <dhammika@gmail.com>
This commit is contained in:
Dhammika Pathirana
2022-02-28 16:37:09 -08:00
parent 27dadba52c
commit b2ad8342d2
2 changed files with 27 additions and 0 deletions

View File

@@ -37,3 +37,8 @@ bytes = "1.0.1"
hex-literal = "0.3" hex-literal = "0.3"
tempfile = "3.2" tempfile = "3.2"
webpki = "0.21" webpki = "0.21"
criterion = "0.3"
[[bench]]
name = "benchmarks"
harness = false

View File

@@ -0,0 +1,22 @@
#![allow(unused)]
use criterion::{criterion_group, criterion_main, Criterion};
use zenith_utils::zid;
pub fn bench_zid_stringify(c: &mut Criterion) {
// Can only use public methods.
let ztl = zid::ZTenantTimelineId::generate();
c.bench_function("zid.to_string", |b| {
b.iter(|| {
// FIXME measurement overhead?
//for _ in 0..1000 {
// ztl.tenant_id.to_string();
//}
ztl.tenant_id.to_string();
})
});
}
criterion_group!(benches, bench_zid_stringify);
criterion_main!(benches);