mirror of
https://github.com/scottlamb/moonfire-nvr.git
synced 2025-01-26 06:03:18 -05:00
reuse reqwest client in serve_camera_html bench
This makes a huge difference in the reported time - 863 usec rather than 6 milliseconds on my laptop. Part of the difference is in reqwest client setup (it apparently initializes a SSL_CTX that is never used in this test), part fresh connections vs keepalive, part I don't know what. None of it seems relevant to the logic I want to test.
This commit is contained in:
parent
1cf27c189f
commit
4806c62ca1
9
Cargo.lock
generated
9
Cargo.lock
generated
@ -267,7 +267,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
[[package]]
|
||||
name = "hyper"
|
||||
version = "0.10.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
source = "git+https://github.com/scottlamb/hyper?branch=moonfire-on-0.10.x#601e52f7decfbe4b34f278058383f774fba7cb4f"
|
||||
dependencies = [
|
||||
"httparse 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -283,6 +283,12 @@ dependencies = [
|
||||
"url 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hyper"
|
||||
version = "0.10.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
replace = "hyper 0.10.5 (git+https://github.com/scottlamb/hyper?branch=moonfire-on-0.10.x)"
|
||||
|
||||
[[package]]
|
||||
name = "hyper"
|
||||
version = "0.11.0-a.0"
|
||||
@ -1230,6 +1236,7 @@ dependencies = [
|
||||
"checksum gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0912515a8ff24ba900422ecda800b52f4016a56251922d397c576bf92c690518"
|
||||
"checksum http-entity 0.0.1 (git+https://github.com/scottlamb/http-entity?branch=hyper-0.11.x)" = "<none>"
|
||||
"checksum httparse 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a6e7a63e511f9edffbab707141fbb8707d1a3098615fb2adbd5769cdfcc9b17d"
|
||||
"checksum hyper 0.10.5 (git+https://github.com/scottlamb/hyper?branch=moonfire-on-0.10.x)" = "<none>"
|
||||
"checksum hyper 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)" = "43a15e3273b2133aaac0150478ab443fb89f15c3de41d8d93d8f3bb14bf560f6"
|
||||
"checksum hyper 0.11.0-a.0 (git+https://github.com/hyperium/hyper)" = "<none>"
|
||||
"checksum hyper 0.11.0-a.0 (git+https://github.com/scottlamb/hyper?branch=moonfire-on-0.11.x)" = "<none>"
|
||||
|
@ -72,3 +72,4 @@ debug = true
|
||||
|
||||
[replace]
|
||||
"https://github.com/hyperium/hyper#hyper:0.11.0-a.0" = { git = "https://github.com/scottlamb/hyper", branch = "moonfire-on-0.11.x" }
|
||||
"hyper:0.10.5" = { git = "https://github.com/scottlamb/hyper", branch = "moonfire-on-0.10.x" }
|
||||
|
@ -652,13 +652,15 @@ mod bench {
|
||||
let url = reqwest::Url::parse(&format!("{}/cameras/{}/", server.base_url,
|
||||
*testutil::TEST_CAMERA_UUID)).unwrap();
|
||||
let mut buf = Vec::new();
|
||||
b.iter(|| {
|
||||
let client = reqwest::Client::new().unwrap();
|
||||
let client = reqwest::Client::new().unwrap();
|
||||
let mut f = || {
|
||||
let mut resp = client.get(url.clone()).send().unwrap();
|
||||
assert_eq!(*resp.status(), reqwest::StatusCode::Ok);
|
||||
buf.clear();
|
||||
use std::io::Read;
|
||||
resp.read_to_end(&mut buf).unwrap();
|
||||
});
|
||||
};
|
||||
f(); // warm.
|
||||
b.iter(f);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user