Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
Mirrored projects
jsonrpsee
Commits
00896055
Unverified
Commit
00896055
authored
Jul 12, 2022
by
Alexandru Vasile
Browse files
bench: Add bench for custom HTTP headers
Signed-off-by:
Alexandru Vasile
<
alexandru.vasile@parity.io
>
parent
97f93895
Changes
1
Hide whitespace changes
Inline
Side-by-side
benches/bench.rs
View file @
00896055
...
...
@@ -90,6 +90,7 @@ trait RequestBencher {
round_trip
(
&
rt
,
crit
,
client
.clone
(),
"http_round_trip"
,
Self
::
REQUEST_TYPE
);
http_concurrent_conn_calls
(
&
rt
,
crit
,
&
url
,
"http_concurrent_conn_calls"
,
Self
::
REQUEST_TYPE
);
batch_round_trip
(
&
rt
,
crit
,
client
,
"http_batch_requests"
,
Self
::
REQUEST_TYPE
);
http_custom_headers_round_trip
(
&
rt
,
crit
,
&
url
,
"http_custom_headers_round_trip"
,
Self
::
REQUEST_TYPE
);
}
fn
websocket_benches
(
crit
:
&
mut
Criterion
)
{
...
...
@@ -308,3 +309,25 @@ fn http_concurrent_conn_calls(rt: &TokioRuntime, crit: &mut Criterion, url: &str
}
group
.finish
();
}
/// Bench `round_trip` with different header sizes.
fn
http_custom_headers_round_trip
(
rt
:
&
TokioRuntime
,
crit
:
&
mut
Criterion
,
url
:
&
str
,
name
:
&
str
,
request
:
RequestType
,
)
{
// 1 KiB = 1024 bytes
const
KIB
:
usize
=
1024
;
for
header_size
in
[
1
*
KIB
,
2
*
KIB
,
8
*
KIB
]
{
let
mut
headers
=
HeaderMap
::
new
();
headers
.insert
(
"key"
,
"A"
.repeat
(
header_size
)
.parse
()
.unwrap
());
let
client
=
Arc
::
new
(
http_client
(
url
,
headers
));
let
bench_name
=
format!
(
"{}/{}"
,
name
,
header_size
);
round_trip
(
rt
,
crit
,
client
,
&
bench_name
,
request
);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment