Skip to content

Commit 4a86e16

Browse files
authored
Add benchmarks (#2080)
1 parent 3aa5026 commit 4a86e16

File tree

1 file changed

+35
-9
lines changed

1 file changed

+35
-9
lines changed

opentelemetry/benches/attributes.rs

+35-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
/* OS: Ubuntu 22.04.4 LTS (5.15.153.1-microsoft-standard-WSL2)
22
Hardware: Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz, 16vCPUs,
33
RAM: 64.0 GB
4-
| Test | Average time|
5-
|--------------------------------|-------------|
6-
| CreateOTelKey_Static | 1.2 ns |
7-
| CreateOTelKey_Owned | 12.6 ns |
8-
| CreateOTelKey_Arc | 23.35 ns |
9-
| CreateOTelKeyValue | 3.24 ns |
10-
| CreateTupleKeyValue | 671 ps |
11-
| CreateOtelKeyValueArray | 18.4 ns |
12-
| CreateTupleKeyValueArray | 2.73 ns |
4+
| Test | Average time|
5+
|--------------------------------------------------|-------------|
6+
| CreateOTelKey_Static | 1.2 ns |
7+
| CreateOTelKey_Owned | 12.6 ns |
8+
| CreateOTelKey_Arc | 23.35 ns |
9+
| CreateOTelKeyValue | 3.24 ns |
10+
| CreateTupleKeyValue | 671 ps |
11+
| CreateOtelKeyValueArray | 18.4 ns |
12+
| CreateOtelKeyValueArrayWithMixedValueTypes | 18.1 ns |
13+
| CreateOtelKeyValueArrayWithNonStaticValues | 90.1 ns |
14+
| CreateTupleKeyValueArray | 2.73 ns |
1315
*/
1416

1517
use criterion::{black_box, criterion_group, criterion_main, Criterion};
@@ -65,6 +67,30 @@ fn attributes_creation(c: &mut Criterion) {
6567
});
6668
});
6769

70+
c.bench_function("CreateOtelKeyValueArrayWithMixedValueTypes", |b| {
71+
b.iter(|| {
72+
let _v1 = black_box([
73+
KeyValue::new("attribute1", true),
74+
KeyValue::new("attribute2", 100),
75+
KeyValue::new("attribute3", 100.5),
76+
KeyValue::new("attribute4", "value"),
77+
]);
78+
});
79+
});
80+
81+
let value = "value1value2value3value4".to_owned();
82+
83+
c.bench_function("CreateOtelKeyValueArrayWithNonStaticValues", |b| {
84+
b.iter(|| {
85+
let _v1 = black_box([
86+
KeyValue::new("attribute1", value[0..6].to_owned()), // value[0..6] = "value1"
87+
KeyValue::new("attribute2", value[6..12].to_owned()), // value[6..12] = "value2"
88+
KeyValue::new("attribute3", value[12..18].to_owned()), // value[12..18] = "value3"
89+
KeyValue::new("attribute4", value[18..24].to_owned()), // value[18..24] = "value4"
90+
]);
91+
});
92+
});
93+
6894
c.bench_function("CreateTupleKeyValueArray", |b| {
6995
b.iter(|| {
7096
let _v1 = black_box([

0 commit comments

Comments
 (0)