File tree 5 files changed +30
-4
lines changed
5 files changed +30
-4
lines changed Original file line number Diff line number Diff line change 57
57
- name : workaround MSRV issues
58
58
if : matrix.version.name == 'msrv'
59
59
run : |
60
+ cargo update -p=ciborium --precise=0.2.1
61
+ cargo update -p=ciborium-ll --precise=0.2.1
60
62
cargo update -p=clap --precise=4.3.24
61
63
cargo update -p=clap_lex --precise=0.5.0
62
64
cargo update -p=anstyle --precise=1.0.2
Original file line number Diff line number Diff line change @@ -113,6 +113,7 @@ actix-web = "4"
113
113
114
114
async-stream = " 0.3"
115
115
criterion = { version = " 0.5" , features = [" html_reports" ] }
116
+ divan = " 0.1.11"
116
117
env_logger = " 0.10"
117
118
futures-util = { version = " 0.3.17" , default-features = false , features = [" alloc" ] }
118
119
memchr = " 2.4"
@@ -140,3 +141,7 @@ required-features = ["http2", "rustls-0_21"]
140
141
name = " response-body-compression"
141
142
harness = false
142
143
required-features = [" compress-brotli" , " compress-gzip" , " compress-zstd" ]
144
+
145
+ [[bench ]]
146
+ name = " date-formatting"
147
+ harness = false
Original file line number Diff line number Diff line change
1
+ use std:: time:: SystemTime ;
2
+
3
+ use actix_http:: header:: HttpDate ;
4
+ use divan:: { black_box, AllocProfiler , Bencher } ;
5
+
6
+ #[ global_allocator]
7
+ static ALLOC : AllocProfiler = AllocProfiler :: system ( ) ;
8
+
9
+ #[ divan:: bench]
10
+ fn date_formatting ( b : Bencher < ' _ , ' _ > ) {
11
+ let now = SystemTime :: now ( ) ;
12
+
13
+ b. bench ( || {
14
+ black_box ( HttpDate :: from ( black_box ( now) ) . to_string ( ) ) ;
15
+ } )
16
+ }
17
+
18
+ fn main ( ) {
19
+ divan:: main ( ) ;
20
+ }
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ impl Date {
28
28
29
29
fn update ( & mut self ) {
30
30
self . pos = 0 ;
31
- write ! ( self , "{}" , httpdate:: fmt_http_date ( SystemTime :: now( ) ) ) . unwrap ( ) ;
31
+ write ! ( self , "{}" , httpdate:: HttpDate :: from ( SystemTime :: now( ) ) ) . unwrap ( ) ;
32
32
}
33
33
}
34
34
Original file line number Diff line number Diff line change @@ -24,8 +24,7 @@ impl FromStr for HttpDate {
24
24
25
25
impl fmt:: Display for HttpDate {
26
26
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
27
- let date_str = httpdate:: fmt_http_date ( self . 0 ) ;
28
- f. write_str ( & date_str)
27
+ httpdate:: HttpDate :: from ( self . 0 ) . fmt ( f)
29
28
}
30
29
}
31
30
@@ -37,7 +36,7 @@ impl TryIntoHeaderValue for HttpDate {
37
36
let mut wrt = MutWriter ( & mut buf) ;
38
37
39
38
// unwrap: date output is known to be well formed and of known length
40
- write ! ( wrt, "{}" , httpdate :: fmt_http_date ( self . 0 ) ) . unwrap ( ) ;
39
+ write ! ( wrt, "{}" , self ) . unwrap ( ) ;
41
40
42
41
HeaderValue :: from_maybe_shared ( buf. split ( ) . freeze ( ) )
43
42
}
You can’t perform that action at this time.
0 commit comments