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 } ;
2
16
use opentelemetry:: { global, metrics:: Counter , KeyValue } ;
3
17
4
18
// Run this benchmark with:
@@ -17,21 +31,21 @@ fn criterion_benchmark(c: &mut Criterion) {
17
31
fn counter_add ( c : & mut Criterion ) {
18
32
let counter = create_counter ( ) ;
19
33
20
- c. bench_function ( "Counter_NoAttributes " , |b| {
34
+ c. bench_function ( "NoAttributes " , |b| {
21
35
b. iter ( || {
22
36
counter. add ( 1 , & [ ] ) ;
23
37
} ) ;
24
38
} ) ;
25
39
26
- c. bench_function ( "Counter_AddWithInlineStaticAttributes " , |b| {
40
+ c. bench_function ( "AddWithInlineStaticAttributes " , |b| {
27
41
b. iter ( || {
28
42
counter. add (
29
43
1 ,
30
44
& [
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" ) ,
35
49
] ,
36
50
) ;
37
51
} ) ;
@@ -44,19 +58,19 @@ fn counter_add(c: &mut Criterion) {
44
58
KeyValue :: new ( "attribute4" , "value4" ) ,
45
59
] ;
46
60
47
- c. bench_function ( "Counter_AddWithStaticArray " , |b| {
61
+ c. bench_function ( "AddWithStaticArray " , |b| {
48
62
b. iter ( || {
49
63
counter. add ( 1 , & kv) ;
50
64
} ) ;
51
65
} ) ;
52
66
53
- c. bench_function ( "Counter_AddWithDynamicAttributes " , |b| {
67
+ c. bench_function ( "AddWithDynamicAttributes " , |b| {
54
68
b. iter_batched (
55
69
|| {
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 ) ;
60
74
61
75
( value1, value2, value3, value4)
62
76
} ,
0 commit comments