File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -170,6 +170,22 @@ fn bench_parse_strftime_localized(c: &mut Criterion) {
170
170
} ) ;
171
171
}
172
172
173
+ fn bench_format_to_string ( c : & mut Criterion ) {
174
+ let dt = Local :: now ( ) ;
175
+ c. bench_function ( "bench_format_to_string" , |b| {
176
+ b. iter ( || black_box ( dt) . format_to_string ( "%Y-%m-%dT%H:%M:%S%.f%:z" ) )
177
+ } ) ;
178
+ }
179
+
180
+ fn bench_format_with ( c : & mut Criterion ) {
181
+ let dt = Local :: now ( ) ;
182
+ let fmt_items: Vec < _ > = StrftimeItems :: new ( "%Y-%m-%dT%H:%M:%S%.f%:z" ) . collect ( ) ;
183
+ let formatter = DateTime :: formatter ( & fmt_items) . unwrap ( ) ;
184
+ c. bench_function ( "bench_format_with" , |b| {
185
+ b. iter ( || format ! ( "{}" , black_box( dt) . format_with( & formatter) ) )
186
+ } ) ;
187
+ }
188
+
173
189
fn bench_format ( c : & mut Criterion ) {
174
190
let dt = Local :: now ( ) ;
175
191
c. bench_function ( "bench_format" , |b| {
@@ -235,6 +251,8 @@ criterion_group!(
235
251
bench_get_local_time,
236
252
bench_parse_strftime,
237
253
bench_format,
254
+ bench_format_to_string,
255
+ bench_format_with,
238
256
bench_format_with_items,
239
257
bench_format_manual,
240
258
bench_naivedate_add_signed,
You can’t perform that action at this time.
0 commit comments