-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wraps the `neqo-client` and `neqo-server` code, starts the server and runs various benchmarks through the client. Benchmarks: - single-request-1gb - single-request-1mb - requests-per-second - handshakes-per-second
- Loading branch information
Showing
10 changed files
with
255 additions
and
39 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,98 @@ | ||
// 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, BatchSize, Criterion, Throughput}; | ||
use tokio::runtime::Runtime; | ||
|
||
struct Benchmark { | ||
name: String, | ||
requests: Vec<u64>, | ||
/// Download resources in series using separate connections. | ||
download_in_series: bool, | ||
} | ||
|
||
fn transfer(c: &mut Criterion) { | ||
neqo_crypto::init_db(PathBuf::from_str("../test-fixture/db").unwrap()); | ||
|
||
let done_sender = spawn_server(); | ||
|
||
for Benchmark { | ||
name, | ||
requests, | ||
download_in_series, | ||
} in [ | ||
Benchmark { | ||
name: "single-request-1gb".to_string(), | ||
requests: vec![1024 * 1024 * 1024], | ||
download_in_series: false, | ||
}, | ||
Benchmark { | ||
name: "single-request-1mb".to_string(), | ||
requests: vec![1024 * 1024], | ||
download_in_series: false, | ||
}, | ||
Benchmark { | ||
name: "requests-per-second(10_000)".to_string(), | ||
// TODO: Reconsider value. | ||
requests: vec![1; 10_000], | ||
download_in_series: false, | ||
}, | ||
Benchmark { | ||
name: "handshakes-per-second(100)".to_string(), | ||
// TODO: Reconsider value. | ||
requests: vec![1; 100], | ||
download_in_series: true, | ||
}, | ||
] { | ||
let mut group = c.benchmark_group(name); | ||
group.throughput(if requests[0] > 1 { | ||
Throughput::Bytes(requests[0]) | ||
} else { | ||
Throughput::Elements(requests.len() as u64) | ||
}); | ||
group.bench_function("client", |b| { | ||
b.to_async(Runtime::new().unwrap()).iter_batched( | ||
|| { | ||
neqo_bin::client::client(neqo_bin::client::Args::new( | ||
&requests, | ||
download_in_series, | ||
)) | ||
}, | ||
|client| async move { | ||
client.await.unwrap(); | ||
}, | ||
BatchSize::PerIteration, | ||
); | ||
}); | ||
group.finish(); | ||
} | ||
|
||
done_sender.send(()).unwrap(); | ||
} | ||
|
||
fn spawn_server() -> tokio::sync::oneshot::Sender<()> { | ||
let (done_sender, mut done_receiver) = tokio::sync::oneshot::channel(); | ||
std::thread::spawn(move || { | ||
Runtime::new().unwrap().block_on(async { | ||
let mut server = Box::pin(neqo_bin::server::server(neqo_bin::server::Args::default())); | ||
tokio::select! { | ||
_ = &mut done_receiver => {} | ||
_ = &mut server => {} | ||
} | ||
}); | ||
}); | ||
done_sender | ||
} | ||
|
||
criterion_group! { | ||
name = benches; | ||
// TODO: Reconsider | ||
config = Criterion::default().sample_size(10); | ||
targets = transfer | ||
} | ||
criterion_main!(benches); |
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,14 @@ | ||
// 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 clap::Parser; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), neqo_bin::client::Error> { | ||
let args = neqo_bin::client::Args::parse(); | ||
|
||
neqo_bin::client::client(args).await | ||
} |
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,14 @@ | ||
// 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 clap::Parser; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), std::io::Error> { | ||
let args = neqo_bin::server::Args::parse(); | ||
|
||
neqo_bin::server::server(args).await | ||
} |
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
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
Oops, something went wrong.