forked from hyperium/hyper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(client): change HttpConnecting to hold Arc<Config> instead of in…
…lined fields
- Loading branch information
1 parent
f71304b
commit 8b878a8
Showing
3 changed files
with
71 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#![feature(test)] | ||
#![deny(warnings)] | ||
|
||
extern crate test; | ||
|
||
use tokio::net::TcpListener; | ||
use tokio::runtime::current_thread::Runtime; | ||
use hyper::client::connect::{Destination, HttpConnector}; | ||
use hyper::service::Service; | ||
use http::Uri; | ||
|
||
#[bench] | ||
fn http_connector(b: &mut test::Bencher) { | ||
let _ = pretty_env_logger::try_init(); | ||
let mut rt = Runtime::new().unwrap(); | ||
let mut listener = rt.block_on(TcpListener::bind("127.0.0.1:0")).expect("bind"); | ||
let addr = listener.local_addr().expect("local_addr"); | ||
let uri: Uri = format!("http://{}/", addr).parse().expect("uri parse"); | ||
let dst = Destination::try_from_uri(uri).expect("destination"); | ||
let mut connector = HttpConnector::new(); | ||
|
||
rt.spawn(async move { | ||
loop { | ||
let _ = listener.accept().await; | ||
} | ||
}); | ||
|
||
|
||
b.iter(|| { | ||
rt.block_on(async { | ||
connector.call(dst.clone()).await.expect("connect"); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters