Skip to content

Commit

Permalink
Tidy up TestRecorder/PrintRecorder
Browse files Browse the repository at this point in the history
  • Loading branch information
joshka committed Aug 25, 2024
1 parent 448b700 commit 9ee8715
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
14 changes: 4 additions & 10 deletions metrics/benches/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use metrics::{
};
use rand::{thread_rng, Rng};

#[derive(Default)]
struct TestRecorder;

impl Recorder for TestRecorder {
fn describe_counter(&self, _: KeyName, _: Option<Unit>, _: SharedString) {}
fn describe_gauge(&self, _: KeyName, _: Option<Unit>, _: SharedString) {}
Expand Down Expand Up @@ -59,27 +59,21 @@ fn macro_benchmark(c: &mut Criterion) {
});
});
group.bench_function("local_initialized/no_labels", |b| {
let recorder = TestRecorder;

metrics::with_local_recorder(&recorder, || {
metrics::with_local_recorder(&TestRecorder, || {
b.iter(|| {
counter!("counter_bench").increment(42);
});
});
});
group.bench_function("local_initialized/with_static_labels", |b| {
let recorder = TestRecorder;

metrics::with_local_recorder(&recorder, || {
metrics::with_local_recorder(&TestRecorder, || {
b.iter(|| {
counter!("counter_bench", "request" => "http", "svc" => "admin").increment(42);
});
});
});
group.bench_function("local_initialized/with_dynamic_labels", |b| {
let recorder = TestRecorder;

metrics::with_local_recorder(&recorder, || {
metrics::with_local_recorder(&TestRecorder, || {
let label_val = thread_rng().gen::<u64>().to_string();
b.iter(move || {
counter!("counter_bench", "request" => "http", "uid" => label_val.clone())
Expand Down
1 change: 0 additions & 1 deletion metrics/examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ impl HistogramFn for PrintHandle {
}
}

#[derive(Default)]
struct PrintRecorder;

impl Recorder for PrintRecorder {
Expand Down

0 comments on commit 9ee8715

Please sign in to comment.