@@ -30,7 +30,7 @@ fn http1_post(b: &mut test::Bencher) {
30
30
}
31
31
32
32
#[ bench]
33
- fn http1_body_100kb ( b : & mut test:: Bencher ) {
33
+ fn http1_body_both_100kb ( b : & mut test:: Bencher ) {
34
34
let body = & [ b'x' ; 1024 * 100 ] ;
35
35
opts ( )
36
36
. method ( Method :: POST )
@@ -40,7 +40,7 @@ fn http1_body_100kb(b: &mut test::Bencher) {
40
40
}
41
41
42
42
#[ bench]
43
- fn http1_body_10mb ( b : & mut test:: Bencher ) {
43
+ fn http1_body_both_10mb ( b : & mut test:: Bencher ) {
44
44
let body = & [ b'x' ; 1024 * 1024 * 10 ] ;
45
45
opts ( )
46
46
. method ( Method :: POST )
@@ -50,12 +50,22 @@ fn http1_body_10mb(b: &mut test::Bencher) {
50
50
}
51
51
52
52
#[ bench]
53
- fn http1_get_parallel ( b : & mut test:: Bencher ) {
53
+ fn http1_parallel_x10_empty ( b : & mut test:: Bencher ) {
54
54
opts ( )
55
55
. parallel ( 10 )
56
56
. bench ( b)
57
57
}
58
58
59
+ #[ bench]
60
+ fn http1_parallel_x10_req_10mb ( b : & mut test:: Bencher ) {
61
+ let body = & [ b'x' ; 1024 * 1024 * 10 ] ;
62
+ opts ( )
63
+ . parallel ( 10 )
64
+ . method ( Method :: POST )
65
+ . request_body ( body)
66
+ . bench ( b)
67
+ }
68
+
59
69
#[ bench]
60
70
fn http2_get ( b : & mut test:: Bencher ) {
61
71
opts ( )
@@ -73,17 +83,42 @@ fn http2_post(b: &mut test::Bencher) {
73
83
}
74
84
75
85
#[ bench]
76
- fn http2_get_parallel ( b : & mut test:: Bencher ) {
86
+ fn http2_req_100kb ( b : & mut test:: Bencher ) {
87
+ let body = & [ b'x' ; 1024 * 100 ] ;
88
+ opts ( )
89
+ . http2 ( )
90
+ . method ( Method :: POST )
91
+ . request_body ( body)
92
+ . bench ( b)
93
+ }
94
+
95
+ #[ bench]
96
+ fn http2_parallel_x10_empty ( b : & mut test:: Bencher ) {
77
97
opts ( )
78
98
. http2 ( )
79
99
. parallel ( 10 )
80
100
. bench ( b)
81
101
}
82
102
103
+ #[ bench]
104
+ fn http2_parallel_x10_req_10mb ( b : & mut test:: Bencher ) {
105
+ let body = & [ b'x' ; 1024 * 1024 * 10 ] ;
106
+ opts ( )
107
+ . http2 ( )
108
+ . parallel ( 10 )
109
+ . method ( Method :: POST )
110
+ . request_body ( body)
111
+ . http2_stream_window ( std:: u32:: MAX >> 1 )
112
+ . http2_conn_window ( std:: u32:: MAX >> 1 )
113
+ . bench ( b)
114
+ }
115
+
83
116
// ==== Benchmark Options =====
84
117
85
118
struct Opts {
86
119
http2 : bool ,
120
+ http2_stream_window : Option < u32 > ,
121
+ http2_conn_window : Option < u32 > ,
87
122
parallel_cnt : u32 ,
88
123
request_method : Method ,
89
124
request_body : Option < & ' static [ u8 ] > ,
@@ -93,6 +128,8 @@ struct Opts {
93
128
fn opts ( ) -> Opts {
94
129
Opts {
95
130
http2 : false ,
131
+ http2_stream_window : None ,
132
+ http2_conn_window : None ,
96
133
parallel_cnt : 1 ,
97
134
request_method : Method :: GET ,
98
135
request_body : None ,
@@ -106,6 +143,16 @@ impl Opts {
106
143
self
107
144
}
108
145
146
+ fn http2_stream_window ( mut self , sz : impl Into < Option < u32 > > ) -> Self {
147
+ self . http2_stream_window = sz. into ( ) ;
148
+ self
149
+ }
150
+
151
+ fn http2_conn_window ( mut self , sz : impl Into < Option < u32 > > ) -> Self {
152
+ self . http2_conn_window = sz. into ( ) ;
153
+ self
154
+ }
155
+
109
156
fn method ( mut self , m : Method ) -> Self {
110
157
self . request_method = m;
111
158
self
@@ -133,11 +180,13 @@ impl Opts {
133
180
134
181
b. bytes = self . response_body . len ( ) as u64 + self . request_body . map ( |b| b. len ( ) ) . unwrap_or ( 0 ) as u64 ;
135
182
136
- let addr = spawn_hello ( & mut rt, self . response_body ) ;
183
+ let addr = spawn_hello ( & mut rt, & self ) ;
137
184
138
185
let connector = HttpConnector :: new ( 1 ) ;
139
186
let client = hyper:: Client :: builder ( )
140
187
. http2_only ( self . http2 )
188
+ . http2_initial_stream_window_size ( self . http2_stream_window )
189
+ . http2_initial_connection_window_size ( self . http2_conn_window )
141
190
. build :: < _ , Body > ( connector) ;
142
191
143
192
let url: hyper:: Uri = format ! ( "http://{}/hello" , addr) . parse ( ) . unwrap ( ) ;
@@ -181,12 +230,19 @@ impl Opts {
181
230
}
182
231
}
183
232
184
- fn spawn_hello ( rt : & mut Runtime , body : & ' static [ u8 ] ) -> SocketAddr {
233
+ fn spawn_hello ( rt : & mut Runtime , opts : & Opts ) -> SocketAddr {
185
234
use hyper:: service:: { service_fn} ;
186
235
let addr = "127.0.0.1:0" . parse ( ) . unwrap ( ) ;
187
236
188
- let srv = Server :: bind ( & addr)
189
- . serve ( move || {
237
+ let body = opts. response_body ;
238
+ let mut builder = Server :: bind ( & addr)
239
+ . http2_only ( opts. http2 ) ;
240
+ // api woopsie
241
+ builder
242
+ . http2_initial_stream_window_size ( opts. http2_stream_window )
243
+ . http2_initial_connection_window_size ( opts. http2_conn_window ) ;
244
+
245
+ let srv = builder. serve ( move || {
190
246
service_fn ( move |req : Request < Body > | {
191
247
req
192
248
. into_body ( )
0 commit comments