mirror of
https://github.com/scottlamb/moonfire-nvr.git
synced 2024-12-27 15:45:55 -05:00
fix some reqwest upgrade brokenness in benches
This commit is contained in:
parent
f7da085335
commit
a26c3d1649
13
src/mp4.rs
13
src/mp4.rs
@ -2338,19 +2338,20 @@ mod bench {
|
|||||||
testutil::init();
|
testutil::init();
|
||||||
let server = &*SERVER;
|
let server = &*SERVER;
|
||||||
let p = server.generated_len;
|
let p = server.generated_len;
|
||||||
let mut buf = Vec::with_capacity(p as usize);
|
|
||||||
b.bytes = p;
|
b.bytes = p;
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
|
let mut rt = tokio::runtime::Runtime::new().unwrap();
|
||||||
let mut run = || {
|
let mut run = || {
|
||||||
let mut resp =
|
rt.block_on(async {
|
||||||
|
let resp =
|
||||||
client.get(server.url.clone())
|
client.get(server.url.clone())
|
||||||
.header(reqwest::header::RANGE, format!("bytes=0-{}", p - 1))
|
.header(reqwest::header::RANGE, format!("bytes=0-{}", p - 1))
|
||||||
.send()
|
.send()
|
||||||
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
buf.clear();
|
let b = resp.bytes().await.unwrap();
|
||||||
use std::io::Read;
|
assert_eq!(p, b.len() as u64);
|
||||||
let size = resp.read_to_end(&mut buf).unwrap();
|
});
|
||||||
assert_eq!(p, size as u64);
|
|
||||||
};
|
};
|
||||||
run(); // warm.
|
run(); // warm.
|
||||||
b.iter(run);
|
b.iter(run);
|
||||||
|
10
src/web.rs
10
src/web.rs
@ -1398,14 +1398,14 @@ mod bench {
|
|||||||
let server = &*SERVER;
|
let server = &*SERVER;
|
||||||
let url = reqwest::Url::parse(&format!("{}/api/cameras/{}/main/recordings", server.base_url,
|
let url = reqwest::Url::parse(&format!("{}/api/cameras/{}/main/recordings", server.base_url,
|
||||||
server.test_camera_uuid)).unwrap();
|
server.test_camera_uuid)).unwrap();
|
||||||
let mut buf = Vec::new();
|
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
|
let mut rt = tokio::runtime::Runtime::new().unwrap();
|
||||||
let mut f = || {
|
let mut f = || {
|
||||||
let mut resp = client.get(url.clone()).send().unwrap();
|
rt.block_on(async {
|
||||||
|
let resp = client.get(url.clone()).send().await.unwrap();
|
||||||
assert_eq!(resp.status(), reqwest::StatusCode::OK);
|
assert_eq!(resp.status(), reqwest::StatusCode::OK);
|
||||||
buf.clear();
|
let _b = resp.bytes().await.unwrap();
|
||||||
use std::io::Read;
|
});
|
||||||
resp.read_to_end(&mut buf).unwrap();
|
|
||||||
};
|
};
|
||||||
f(); // warm.
|
f(); // warm.
|
||||||
b.iter(f);
|
b.iter(f);
|
||||||
|
Loading…
Reference in New Issue
Block a user