Skip to content

Commit d171e34

Browse files
committed
Address PR comments
1 parent 4af5e6b commit d171e34

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

opentelemetry/benches/metrics.rs

+27-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
use criterion::{black_box, criterion_group, criterion_main, BatchSize, Criterion};
1+
/*
2+
Benchmark Results:
3+
criterion = "0.5.1"
4+
OS: Ubuntu 22.04.4 LTS (5.15.153.1-microsoft-standard-WSL2)
5+
Hardware: Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz, 16vCPUs,
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 |
13+
*/
14+
15+
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
216
use opentelemetry::{global, metrics::Counter, KeyValue};
317

418
// Run this benchmark with:
@@ -17,21 +31,21 @@ fn criterion_benchmark(c: &mut Criterion) {
1731
fn counter_add(c: &mut Criterion) {
1832
let counter = create_counter();
1933

20-
c.bench_function("Counter_NoAttributes", |b| {
34+
c.bench_function("NoAttributes", |b| {
2135
b.iter(|| {
2236
counter.add(1, &[]);
2337
});
2438
});
2539

26-
c.bench_function("Counter_AddWithInlineStaticAttributes", |b| {
40+
c.bench_function("AddWithInlineStaticAttributes", |b| {
2741
b.iter(|| {
2842
counter.add(
2943
1,
3044
&[
31-
black_box(KeyValue::new("attribute1", "value1")),
32-
black_box(KeyValue::new("attribute2", "value2")),
33-
black_box(KeyValue::new("attribute3", "value3")),
34-
black_box(KeyValue::new("attribute4", "value4")),
45+
KeyValue::new("attribute1", "value1"),
46+
KeyValue::new("attribute2", "value2"),
47+
KeyValue::new("attribute3", "value3"),
48+
KeyValue::new("attribute4", "value4"),
3549
],
3650
);
3751
});
@@ -44,19 +58,19 @@ fn counter_add(c: &mut Criterion) {
4458
KeyValue::new("attribute4", "value4"),
4559
];
4660

47-
c.bench_function("Counter_AddWithStaticArray", |b| {
61+
c.bench_function("AddWithStaticArray", |b| {
4862
b.iter(|| {
4963
counter.add(1, &kv);
5064
});
5165
});
5266

53-
c.bench_function("Counter_AddWithDynamicAttributes", |b| {
67+
c.bench_function("AddWithDynamicAttributes", |b| {
5468
b.iter_batched(
5569
|| {
56-
let value1 = black_box("a".repeat(6)); // Repeat character six times to match the length of value strings used in other benchmarks
57-
let value2 = black_box("b".repeat(6));
58-
let value3 = black_box("c".repeat(6));
59-
let value4 = black_box("d".repeat(6));
70+
let value1 = "a".repeat(6); // Repeat character six times to match the length of value strings used in other benchmarks
71+
let value2 = "b".repeat(6);
72+
let value3 = "c".repeat(6);
73+
let value4 = "d".repeat(6);
6074

6175
(value1, value2, value3, value4)
6276
},

0 commit comments

Comments
 (0)