|
4 | 4 | OS: Ubuntu 22.04.4 LTS (5.15.153.1-microsoft-standard-WSL2)
|
5 | 5 | Hardware: Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz, 16vCPUs,
|
6 | 6 | RAM: 64.0 GB
|
7 |
| - | Test | Average time| |
8 |
| - |--------------------------------|-------------| |
9 |
| - | NoAttributes | 1.1616 ns | |
10 |
| - | AddWithInlineStaticAttributes | 13.296 ns | |
11 |
| - | AddWithStaticArray | 1.1612 ns | |
12 |
| - | AddWithDynamicAttributes | 110.40 ns | |
| 7 | + | Test | Average time| |
| 8 | + |-----------------------------------------------------|-------------| |
| 9 | + | NoAttributes | 1.1616 ns | |
| 10 | + | AddWithInlineStaticAttributes | 13.296 ns | |
| 11 | + | AddWithStaticArray | 1.1612 ns | |
| 12 | + | AddWithDynamicAttributes | 110.40 ns | |
| 13 | + | AddWithDynamicAttributes_WithStringAllocation | 77.338 ns | |
13 | 14 | */
|
14 | 15 |
|
15 |
| -use criterion::{criterion_group, criterion_main, BatchSize, Criterion}; |
| 16 | +use criterion::{black_box, criterion_group, criterion_main, BatchSize, Criterion}; |
16 | 17 | use opentelemetry::{global, metrics::Counter, KeyValue};
|
17 | 18 |
|
18 | 19 | // Run this benchmark with:
|
@@ -87,6 +88,19 @@ fn counter_add(c: &mut Criterion) {
|
87 | 88 | BatchSize::SmallInput,
|
88 | 89 | );
|
89 | 90 | });
|
| 91 | + |
| 92 | + c.bench_function("AddWithDynamicAttributes_WithStringAllocation", |b| { |
| 93 | + b.iter(|| { |
| 94 | + let kv = &[ |
| 95 | + KeyValue::new("attribute1", black_box("value1".to_string())), |
| 96 | + KeyValue::new("attribute2", black_box("value2".to_string())), |
| 97 | + KeyValue::new("attribute3", black_box("value3".to_string())), |
| 98 | + KeyValue::new("attribute4", black_box("value4".to_string())), |
| 99 | + ]; |
| 100 | + |
| 101 | + counter.add(1, kv); |
| 102 | + }); |
| 103 | + }); |
90 | 104 | }
|
91 | 105 |
|
92 | 106 | criterion_group!(benches, criterion_benchmark);
|
|
0 commit comments