diff --git a/.gitignore b/.gitignore index ea8c4bf..eb68687 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +/tmp \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 5c9e216..e00d467 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -48,12 +48,14 @@ version = "0.1.0" dependencies = [ "aquatic", "bittorrent_udp", + "cli_helpers", "indicatif", "mimalloc", "num-format", "plotly", "rand", "rand_distr", + "serde", ] [[package]] diff --git a/aquatic_bench/Cargo.toml b/aquatic_bench/Cargo.toml index afc49c5..ddf376d 100644 --- a/aquatic_bench/Cargo.toml +++ b/aquatic_bench/Cargo.toml @@ -17,9 +17,11 @@ name = "plot_pareto" [dependencies] aquatic = { path = "../aquatic" } bittorrent_udp = { path = "../bittorrent_udp" } +cli_helpers = { path = "../cli_helpers" } indicatif = "0.14" mimalloc = { version = "0.1", default-features = false } num-format = "0.4" plotly = "0.4" rand = { version = "0.7", features = ["small_rng"] } -rand_distr = "0.2" \ No newline at end of file +rand_distr = "0.2" +serde = { version = "1", features = ["derive"] } \ No newline at end of file diff --git a/aquatic_bench/src/bin/bench_handlers/config.rs b/aquatic_bench/src/bin/bench_handlers/config.rs new file mode 100644 index 0000000..256a275 --- /dev/null +++ b/aquatic_bench/src/bin/bench_handlers/config.rs @@ -0,0 +1,16 @@ +use serde::{Serialize, Deserialize}; + + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct BenchConfig { + pub num_rounds: u64, +} + + +impl Default for BenchConfig { + fn default() -> Self { + Self { + num_rounds: 20, + } + } +} \ No newline at end of file diff --git a/aquatic_bench/src/bin/bench_handlers/main.rs b/aquatic_bench/src/bin/bench_handlers/main.rs index 684229e..b67d108 100644 --- a/aquatic_bench/src/bin/bench_handlers/main.rs +++ b/aquatic_bench/src/bin/bench_handlers/main.rs @@ -20,14 +20,17 @@ use rand::{Rng, thread_rng, rngs::SmallRng, SeedableRng}; use aquatic::common::*; use aquatic::config::Config; use bittorrent_udp::converters::*; +use cli_helpers::run_app_with_cli_and_config; mod announce; mod common; +mod config; mod connect; mod scrape; use common::*; +use config::BenchConfig; #[global_allocator] @@ -53,7 +56,15 @@ fn print_results( fn main(){ - let num_rounds = 20; + run_app_with_cli_and_config::( + "aquatic benchmarker", + run + ) +} + + +fn run(bench_config: BenchConfig){ + let num_rounds = bench_config.num_rounds; let mut connect_data = (0.0, 0.0); let mut announce_data = (0.0, 0.0); diff --git a/scripts/bench-handlers.sh b/scripts/bench-handlers.sh index 6e2d975..904d1d5 100755 --- a/scripts/bench-handlers.sh +++ b/scripts/bench-handlers.sh @@ -2,4 +2,4 @@ export RUSTFLAGS="-C target-cpu=native" -cargo run --release --bin bench_handlers \ No newline at end of file +cargo run --release --bin bench_handlers -- $@ \ No newline at end of file