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
97f93895
Unverified
Commit
97f93895
authored
Jul 12, 2022
by
Alexandru Vasile
Browse files
bench: Expose headers for http clients
Signed-off-by:
Alexandru Vasile
<
alexandru.vasile@parity.io
>
parent
0ccfbd7e
Changes
2
Hide whitespace changes
Inline
Side-by-side
benches/bench.rs
View file @
97f93895
...
...
@@ -5,6 +5,7 @@ use futures_util::future::{join_all, FutureExt};
use
futures_util
::
stream
::
FuturesUnordered
;
use
helpers
::{
http_client
,
ws_client
,
SUB_METHOD_NAME
,
UNSUB_METHOD_NAME
};
use
jsonrpsee
::
core
::
client
::{
ClientT
,
SubscriptionClientT
};
use
jsonrpsee
::
http_client
::
HeaderMap
;
use
jsonrpsee
::
types
::{
Id
,
ParamsSer
,
RequestSer
};
use
pprof
::
criterion
::{
Output
,
PProfProfiler
};
use
tokio
::
runtime
::
Runtime
as
TokioRuntime
;
...
...
@@ -85,7 +86,7 @@ trait RequestBencher {
fn
http_benches
(
crit
:
&
mut
Criterion
)
{
let
rt
=
TokioRuntime
::
new
()
.unwrap
();
let
(
url
,
_server
)
=
rt
.block_on
(
helpers
::
http_server
(
rt
.handle
()
.clone
()));
let
client
=
Arc
::
new
(
http_client
(
&
url
));
let
client
=
Arc
::
new
(
http_client
(
&
url
,
HeaderMap
::
new
()
));
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
);
...
...
@@ -293,7 +294,7 @@ fn http_concurrent_conn_calls(rt: &TokioRuntime, crit: &mut Criterion, url: &str
for
conns
in
[
2
,
4
,
8
,
16
,
32
,
64
,
128
,
256
,
512
,
1024
]
{
group
.bench_function
(
format!
(
"{}"
,
conns
),
|
b
|
{
b
.to_async
(
rt
)
.iter_with_setup
(
||
(
0
..
conns
)
.map
(|
_
|
http_client
(
url
)),
||
(
0
..
conns
)
.map
(|
_
|
http_client
(
url
,
HeaderMap
::
new
()
)),
|
clients
|
async
{
let
tasks
=
clients
.map
(|
client
|
{
rt
.spawn
(
async
move
{
...
...
benches/helpers.rs
View file @
97f93895
use
jsonrpsee
::
http_client
::{
HttpClient
,
HttpClientBuilder
};
use
jsonrpsee
::
http_client
::{
HeaderMap
,
HttpClient
,
HttpClientBuilder
};
use
jsonrpsee
::
ws_client
::{
WsClient
,
WsClientBuilder
};
pub
(
crate
)
const
SYNC_FAST_CALL
:
&
str
=
"fast_call"
;
...
...
@@ -181,10 +181,11 @@ fn gen_rpc_module() -> jsonrpsee::RpcModule<()> {
module
}
pub
(
crate
)
fn
http_client
(
url
:
&
str
)
->
HttpClient
{
pub
(
crate
)
fn
http_client
(
url
:
&
str
,
headers
:
HeaderMap
)
->
HttpClient
{
HttpClientBuilder
::
default
()
.max_request_body_size
(
u32
::
MAX
)
.max_concurrent_requests
(
1024
*
1024
)
.set_headers
(
headers
)
.build
(
url
)
.unwrap
()
}
...
...
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