aquatic_bench: enable loading configuration from file

This commit is contained in:
Joakim Frostegård 2020-04-11 14:31:21 +02:00
parent 4691080602
commit 9a1143ffac
6 changed files with 35 additions and 3 deletions

View file

@ -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,
}
}
}

View file

@ -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::<BenchConfig>(
"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);