Skip to content

Commit

Permalink
Do no create a new exporter for each exporter benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
mattbodd committed Dec 17, 2024
1 parent 2044d73 commit 3bbe76a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions opentelemetry-etw-metrics/benches/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ use opentelemetry_sdk::{

use criterion::{criterion_group, criterion_main, Criterion};

async fn export(mut resource_metrics: ResourceMetrics) {
let exporter = MetricsExporter::new();
async fn export(exporter: &MetricsExporter, mut resource_metrics: ResourceMetrics) {
exporter.export(&mut resource_metrics).await.unwrap();
}

Expand Down Expand Up @@ -70,9 +69,11 @@ fn criterion_benchmark(c: &mut Criterion) {
.build()
.unwrap();

let exporter = MetricsExporter::new();

c.bench_function("export", |b| {
b.to_async(&runtime)
.iter(|| export(create_resource_metrics()))
.iter(|| export(&exporter, create_resource_metrics()))
});
}

Expand Down

0 comments on commit 3bbe76a

Please sign in to comment.