diff --git a/opentelemetry/benches/logrecord_types.rs b/opentelemetry/benches/logrecord_types.rs index f6a893ad98..d5f2cd7932 100644 --- a/opentelemetry/benches/logrecord_types.rs +++ b/opentelemetry/benches/logrecord_types.rs @@ -1,11 +1,11 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion}; -use opentelemetry::{logs::AnyValue, Key, KeyValue}; +use opentelemetry::{logs::AnyValue, Key, KeyValue, Value}; // Run this benchmark with: // cargo bench --bench logrecord_types // Results: // CreateOTelKeyValue 2-3 ns -// CreateOTelKeyAnyValue 30 ns +// CreateOTelKeyAnyValue 15 ns // CreateTupleKeyValue < 1 ns fn criterion_benchmark(c: &mut Criterion) { @@ -15,14 +15,15 @@ fn criterion_benchmark(c: &mut Criterion) { fn attributes_creation(c: &mut Criterion) { c.bench_function("CreateOTelKeyValue", |b| { b.iter(|| { - let _v1 = black_box(KeyValue::new("attribute1", "value1")); + let _k1 = black_box(Key::new("attribute1")); + let _v2 = black_box(Value::String("value1".into())); }); }); c.bench_function("CreateOTelKeyAnyValue", |b| { b.iter(|| { let _k= black_box(Key::new("attribute1")); - let _v1 = black_box(AnyValue::String("value1".to_string().into())); + let _v1 = black_box(AnyValue::String("value1".into())); }); });