@@ -38,21 +38,25 @@ fn create_counter(name: &'static str) -> Counter<u64> {
38
38
. build ( ) ;
39
39
let meter = meter_provider. meter ( "benchmarks" ) ;
40
40
41
- meter. u64_counter ( name) . init ( )
41
+ println ! ( "Counter_Created" ) ;
42
+ meter. u64_counter ( name) . init ( )
42
43
}
43
44
44
45
fn criterion_benchmark ( c : & mut Criterion ) {
45
- counter_add ( c) ;
46
+ counter_add_sorted ( c) ;
47
+ counter_add_unsorted ( c) ;
48
+ counter_overflow ( c) ;
46
49
}
47
50
48
- fn counter_add ( c : & mut Criterion ) {
51
+ fn counter_add_sorted ( c : & mut Criterion ) {
49
52
let attribute_values = [
50
53
"value1" , "value2" , "value3" , "value4" , "value5" , "value6" , "value7" , "value8" , "value9" ,
51
54
"value10" ,
52
55
] ;
53
56
57
+ let counter = create_counter ( "Counter_Add_Sorted" ) ;
54
58
c. bench_function ( "Counter_Add_Sorted" , |b| {
55
- let counter = create_counter ( "Counter_Add_Sorted" ) ;
59
+
56
60
b. iter ( || {
57
61
// 4*4*10*10 = 1600 time series.
58
62
let rands = CURRENT_RNG . with ( |rng| {
@@ -79,9 +83,16 @@ fn counter_add(c: &mut Criterion) {
79
83
) ;
80
84
} ) ;
81
85
} ) ;
86
+ }
82
87
83
- c. bench_function ( "Counter_Add_Unsorted" , |b| {
84
- let counter = create_counter ( "Counter_Add_Unsorted" ) ;
88
+ fn counter_add_unsorted ( c : & mut Criterion ) {
89
+ let attribute_values = [
90
+ "value1" , "value2" , "value3" , "value4" , "value5" , "value6" , "value7" , "value8" , "value9" ,
91
+ "value10" ,
92
+ ] ;
93
+
94
+ let counter = create_counter ( "Counter_Add_Unsorted" ) ;
95
+ c. bench_function ( "Counter_Add_Unsorted" , |b| {
85
96
b. iter ( || {
86
97
// 4*4*10*10 = 1600 time series.
87
98
let rands = CURRENT_RNG . with ( |rng| {
@@ -108,14 +119,22 @@ fn counter_add(c: &mut Criterion) {
108
119
) ;
109
120
} ) ;
110
121
} ) ;
122
+ }
111
123
112
- c. bench_function ( "Counter_Overflow" , |b| {
113
- let counter = create_counter ( "Counter_Overflow" ) ;
114
- // Cause overflow.
115
- for v in 0 ..2001 {
116
- counter. add ( 100 , & [ KeyValue :: new ( "A" , v. to_string ( ) ) ] ) ;
117
- }
124
+ fn counter_overflow ( c : & mut Criterion ) {
125
+ let attribute_values = [
126
+ "value1" , "value2" , "value3" , "value4" , "value5" , "value6" , "value7" , "value8" , "value9" ,
127
+ "value10" ,
128
+ ] ;
118
129
130
+ let counter = create_counter ( "Counter_Overflow" ) ;
131
+ println ! ( "Counter_Overflow hello init" ) ;
132
+ // Cause overflow.
133
+ for v in 0 ..2001 {
134
+ counter. add ( 100 , & [ KeyValue :: new ( "A" , v. to_string ( ) ) ] ) ;
135
+ }
136
+
137
+ c. bench_function ( "Counter_Overflow" , |b| {
119
138
b. iter ( || {
120
139
// 4*4*10*10 = 1600 time series.
121
140
let rands = CURRENT_RNG . with ( |rng| {
@@ -134,29 +153,14 @@ fn counter_add(c: &mut Criterion) {
134
153
counter. add (
135
154
1 ,
136
155
& [
137
- KeyValue :: new ( "attribute1" , attribute_values[ index_first_attribute] ) ,
138
156
KeyValue :: new ( "attribute2" , attribute_values[ index_second_attribute] ) ,
139
157
KeyValue :: new ( "attribute3" , attribute_values[ index_third_attribute] ) ,
158
+ KeyValue :: new ( "attribute1" , attribute_values[ index_first_attribute] ) ,
140
159
KeyValue :: new ( "attribute4" , attribute_values[ index_fourth_attribute] ) ,
141
160
] ,
142
161
) ;
143
162
} ) ;
144
163
} ) ;
145
-
146
- c. bench_function ( "ThreadLocal_Random_Generator_5" , |b| {
147
- b. iter ( || {
148
- let __i1 = CURRENT_RNG . with ( |rng| {
149
- let mut rng = rng. borrow_mut ( ) ;
150
- [
151
- rng. gen_range ( 0 ..4 ) ,
152
- rng. gen_range ( 0 ..4 ) ,
153
- rng. gen_range ( 0 ..10 ) ,
154
- rng. gen_range ( 0 ..10 ) ,
155
- rng. gen_range ( 0 ..10 ) ,
156
- ]
157
- } ) ;
158
- } ) ;
159
- } ) ;
160
164
}
161
165
162
166
#[ cfg( not( target_os = "windows" ) ) ]
0 commit comments