mirror of https://github.com/fafhrd91/actix-web
fix test and bench
This commit is contained in:
parent
438451edf2
commit
9e802059f3
|
@ -323,13 +323,14 @@ mod tests {
|
|||
settings.set_date(&mut buf1);
|
||||
let now1 = settings.now();
|
||||
|
||||
sleep_until(Instant::now() + Duration::from_secs(1)).await;
|
||||
sleep_until(Instant::now() + Duration::from_secs(2)).await;
|
||||
yield_now().await;
|
||||
|
||||
let now2 = settings.now();
|
||||
let mut buf2 = BytesMut::with_capacity(DATE_VALUE_LENGTH + 10);
|
||||
settings.set_date(&mut buf2);
|
||||
|
||||
assert!(now2 - now1 > Duration::from_millis(500));
|
||||
assert_ne!(now1, now2);
|
||||
|
||||
assert_ne!(buf1, buf2);
|
||||
|
||||
|
|
|
@ -42,15 +42,15 @@ fn bench_async_burst(c: &mut Criterion) {
|
|||
|
||||
c.bench_function("get_body_async_burst", move |b| {
|
||||
b.iter_custom(|iters| {
|
||||
let client =
|
||||
rt.block_on(async { Client::new().get(url.clone()).freeze().unwrap() });
|
||||
rt.block_on(async {
|
||||
let client = Client::new().get(url.clone()).freeze().unwrap();
|
||||
|
||||
let start = std::time::Instant::now();
|
||||
// benchmark body
|
||||
let resps = rt.block_on(async move {
|
||||
|
||||
let burst = (0..iters).map(|_| client.send());
|
||||
join_all(burst).await
|
||||
});
|
||||
let resps = join_all(burst).await;
|
||||
|
||||
let elapsed = start.elapsed();
|
||||
|
||||
// if there are failed requests that might be an issue
|
||||
|
@ -61,6 +61,7 @@ fn bench_async_burst(c: &mut Criterion) {
|
|||
|
||||
elapsed
|
||||
})
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue