forked from vectordotdev/vector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
metrics_snapshot.rs
32 lines (27 loc) · 997 Bytes
/
metrics_snapshot.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
32
use criterion::{criterion_group, BenchmarkId, Criterion};
fn benchmark(c: &mut Criterion) {
let mut group = c.benchmark_group("metrics_snapshot");
// https://github.com/vectordotdev/vector/runs/1746002475
group.noise_threshold(0.02);
for &cardinality in [0, 1, 10, 100, 1000, 10000].iter() {
group.bench_with_input(
BenchmarkId::new("cardinality", cardinality),
&cardinality,
|b, &cardinality| {
let controller = prepare_metrics(cardinality);
b.iter(|| controller.capture_metrics());
},
);
}
group.finish();
}
fn prepare_metrics(cardinality: usize) -> &'static vector::metrics::Controller {
vector::metrics::init_test();
let controller = vector::metrics::Controller::get().unwrap();
controller.reset();
for idx in 0..cardinality {
metrics::counter!("test", 1, "idx" => idx.to_string());
}
controller
}
criterion_group!(benches, benchmark);