-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bin): add single connection benchmark
Benchmark neqo-server -> neqo-client 1GB transfer using criterion.
- Loading branch information
Showing
10 changed files
with
1,295 additions
and
1,146 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,48 @@ | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
use std::{path::PathBuf, str::FromStr}; | ||
|
||
use criterion::{criterion_group, criterion_main, Criterion, Throughput}; | ||
|
||
fn benchmark_transfer(c: &mut Criterion) { | ||
neqo_crypto::init_db(PathBuf::from_str("../test-fixture/db").unwrap()); | ||
|
||
let runtime = tokio::runtime::Runtime::new().unwrap(); | ||
|
||
let mut group = c.benchmark_group("main"); | ||
group.throughput(Throughput::Bytes(1073741824)); | ||
|
||
let (done_sender, mut done_receiver) = tokio::sync::oneshot::channel(); | ||
std::thread::spawn(move || { | ||
tokio::runtime::Runtime::new().unwrap().block_on(async { | ||
let mut server = Box::pin(neqo_bin::server::server(neqo_bin::server::Args::new())); | ||
tokio::select! { | ||
_ = &mut done_receiver => {} | ||
_ = &mut server => {} | ||
} | ||
}) | ||
}); | ||
|
||
group.bench_function("single-connection", |b| { | ||
b.to_async(&runtime).iter(|| async move { | ||
neqo_bin::client::client(neqo_bin::client::Args::new()) | ||
.await | ||
.unwrap(); | ||
}) | ||
}); | ||
|
||
group.finish(); | ||
|
||
done_sender.send(()).unwrap(); | ||
} | ||
|
||
criterion_group! { | ||
name = transfer; | ||
config = Criterion::default().sample_size(10); | ||
targets = benchmark_transfer | ||
} | ||
criterion_main!(transfer); |
Oops, something went wrong.