Skip to content

Commit f779979

Browse files
committed
avoid intermediary
1 parent 1ff14ae commit f779979

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

opentelemetry/benches/logrecord_types.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use criterion::{black_box, criterion_group, criterion_main, Criterion};
2-
use opentelemetry::{logs::AnyValue, Key, KeyValue};
2+
use opentelemetry::{logs::AnyValue, Key, KeyValue, Value};
33

44
// Run this benchmark with:
55
// cargo bench --bench logrecord_types
66
// Results:
77
// CreateOTelKeyValue 2-3 ns
8-
// CreateOTelKeyAnyValue 30 ns
8+
// CreateOTelKeyAnyValue 15 ns
99
// CreateTupleKeyValue < 1 ns
1010

1111
fn criterion_benchmark(c: &mut Criterion) {
@@ -15,14 +15,15 @@ fn criterion_benchmark(c: &mut Criterion) {
1515
fn attributes_creation(c: &mut Criterion) {
1616
c.bench_function("CreateOTelKeyValue", |b| {
1717
b.iter(|| {
18-
let _v1 = black_box(KeyValue::new("attribute1", "value1"));
18+
let _k1 = black_box(Key::new("attribute1"));
19+
let _v2 = black_box(Value::String("value1".into()));
1920
});
2021
});
2122

2223
c.bench_function("CreateOTelKeyAnyValue", |b| {
2324
b.iter(|| {
2425
let _k= black_box(Key::new("attribute1"));
25-
let _v1 = black_box(AnyValue::String("value1".to_string().into()));
26+
let _v1 = black_box(AnyValue::String("value1".into()));
2627
});
2728
});
2829

0 commit comments

Comments
 (0)