forked from vectordotdev/vector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloki.rs
31 lines (26 loc) · 981 Bytes
/
loki.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use std::convert::TryFrom;
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
use vector::{sinks::loki::valid_label_name, template::Template};
const VALID: [&str; 4] = ["name", " name ", "bee_bop", "a09b"];
const INVALID: [&str; 4] = ["0ab", "*", "", " "];
fn bench_valid_label_name(c: &mut Criterion) {
let mut group = c.benchmark_group("loki");
group.bench_function("valid_label_name", |b| {
for template in VALID {
b.iter_batched(
|| Template::try_from(template).unwrap(),
|label| valid_label_name(&label),
BatchSize::SmallInput,
);
}
for template in INVALID {
b.iter_batched(
|| Template::try_from(template).unwrap(),
|label| valid_label_name(&label),
BatchSize::SmallInput,
);
}
});
}
criterion_group!(benches, bench_valid_label_name);
criterion_main!(benches);