1
1
use criterion:: { black_box, criterion_group, criterion_main, Criterion } ;
2
- use opentelemetry:: { logs:: AnyValue , Key , KeyValue } ;
2
+ use opentelemetry:: { logs:: AnyValue , Key , KeyValue , Value } ;
3
3
4
4
// Run this benchmark with:
5
5
// cargo bench --bench logrecord_types
6
6
// Results:
7
7
// CreateOTelKeyValue 2-3 ns
8
- // CreateOTelKeyAnyValue 30 ns
8
+ // CreateOTelKeyAnyValue 15 ns
9
9
// CreateTupleKeyValue < 1 ns
10
10
11
11
fn criterion_benchmark ( c : & mut Criterion ) {
@@ -15,14 +15,15 @@ fn criterion_benchmark(c: &mut Criterion) {
15
15
fn attributes_creation ( c : & mut Criterion ) {
16
16
c. bench_function ( "CreateOTelKeyValue" , |b| {
17
17
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 ( ) ) ) ;
19
20
} ) ;
20
21
} ) ;
21
22
22
23
c. bench_function ( "CreateOTelKeyAnyValue" , |b| {
23
24
b. iter ( || {
24
25
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 ( ) ) ) ;
26
27
} ) ;
27
28
} ) ;
28
29
0 commit comments