Skip to content

Commit

Permalink
feat(benches): Add bench with reqwest blocking (#397)
Browse files Browse the repository at this point in the history
Signed-off-by: Xuanwo <github@xuanwo.io>

---

This PR will add `reqwest` (with the `blocking` feature enabled) to benchmarks so that we can measure the perf with reqwest(hyper).
  • Loading branch information
Xuanwo authored Aug 19, 2022
1 parent c9cd9a1 commit 7163e8a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ criterion = "0.3"
curl = "0.4.42"
rayon = "1"
rouille = "3"
reqwest = { version = "0.11.10", features = ["blocking"] }

[dependencies.isahc]
path = ".."
Expand Down
16 changes: 16 additions & 0 deletions benchmarks/benches/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,22 @@ fn benchmark(c: &mut Criterion) {
BatchSize::SmallInput,
)
});

c.bench_function("download 64K: reqwest", move |b| {
use reqwest::blocking::Client;

let server = TestServer::static_response(&DATA);
let endpoint = server.endpoint();

b.iter_batched(
Client::new,
|client| {
let req = client.get(&endpoint).build().unwrap();
let _ = client.execute(req).unwrap().copy_to(&mut sink()).unwrap();
},
BatchSize::SmallInput,
)
});
}

criterion_group!(benches, benchmark);
Expand Down

0 comments on commit 7163e8a

Please sign in to comment.