1
1
/*
2
2
The benchmark results:
3
3
criterion = "0.5.1"
4
- OS: Ubuntu 22.04.3 LTS (5.15.146 .1-microsoft-standard-WSL2)
5
- Hardware: AMD EPYC 7763 64-Core Processor - 2.44 GHz , 16vCPUs,
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
6
RAM: 64.0 GB
7
7
| Test | Average time|
8
8
|--------------------------------|-------------|
9
- | Gauge_Add_4 | 586 ns |
9
+ | Gauge_Add | 483.78 ns |
10
10
*/
11
11
12
12
use criterion:: { criterion_group, criterion_main, Criterion } ;
@@ -26,6 +26,11 @@ thread_local! {
26
26
static CURRENT_RNG : RefCell <rngs:: SmallRng > = RefCell :: new( rngs:: SmallRng :: from_entropy( ) ) ;
27
27
}
28
28
29
+ static ATTRIBUTE_VALUES : [ & str ; 10 ] = [
30
+ "value1" , "value2" , "value3" , "value4" , "value5" , "value6" , "value7" , "value8" , "value9" ,
31
+ "value10" ,
32
+ ] ;
33
+
29
34
// Run this benchmark with:
30
35
// cargo bench --bench metric_gauge
31
36
fn create_gauge ( ) -> Gauge < u64 > {
@@ -42,13 +47,8 @@ fn criterion_benchmark(c: &mut Criterion) {
42
47
}
43
48
44
49
fn gauge_record ( c : & mut Criterion ) {
45
- let attribute_values = [
46
- "value1" , "value2" , "value3" , "value4" , "value5" , "value6" , "value7" , "value8" , "value9" ,
47
- "value10" ,
48
- ] ;
49
-
50
50
let gauge = create_gauge ( ) ;
51
- c. bench_function ( "Gauge_Add_4 " , |b| {
51
+ c. bench_function ( "Gauge_Add " , |b| {
52
52
b. iter ( || {
53
53
// 4*4*10*10 = 1600 time series.
54
54
let rands = CURRENT_RNG . with ( |rng| {
@@ -67,10 +67,10 @@ fn gauge_record(c: &mut Criterion) {
67
67
gauge. record (
68
68
1 ,
69
69
& [
70
- KeyValue :: new ( "attribute1" , attribute_values [ index_first_attribute] ) ,
71
- KeyValue :: new ( "attribute2" , attribute_values [ index_second_attribute] ) ,
72
- KeyValue :: new ( "attribute3" , attribute_values [ index_third_attribute] ) ,
73
- KeyValue :: new ( "attribute4" , attribute_values [ index_fourth_attribute] ) ,
70
+ KeyValue :: new ( "attribute1" , ATTRIBUTE_VALUES [ index_first_attribute] ) ,
71
+ KeyValue :: new ( "attribute2" , ATTRIBUTE_VALUES [ index_second_attribute] ) ,
72
+ KeyValue :: new ( "attribute3" , ATTRIBUTE_VALUES [ index_third_attribute] ) ,
73
+ KeyValue :: new ( "attribute4" , ATTRIBUTE_VALUES [ index_fourth_attribute] ) ,
74
74
] ,
75
75
) ;
76
76
} ) ;
0 commit comments