aquatic: add Config struct, use in code

This commit is contained in:
Joakim Frostegård 2020-04-06 20:14:24 +02:00
parent ad1fa5b833
commit e4dfe2852c
6 changed files with 51 additions and 21 deletions

View file

@ -6,6 +6,7 @@ use rand_distr::Pareto;
use aquatic::handlers::*;
use aquatic::common::*;
use aquatic::config::Config;
use aquatic_bench::*;
use crate::common::*;
@ -16,6 +17,7 @@ const ANNOUNCE_REQUESTS: usize = 1_000_000;
pub fn bench(
state: &State,
config: &Config,
requests: Vec<(AnnounceRequest, SocketAddr)>,
) -> (f64, f64) {
let mut responses = Vec::with_capacity(ANNOUNCE_REQUESTS);
@ -26,6 +28,7 @@ pub fn bench(
handle_announce_requests(
&state,
config,
&mut responses,
requests,
);

View file

@ -16,6 +16,7 @@ use num_format::{Locale, ToFormattedString};
use rand::{Rng, thread_rng, rngs::SmallRng, SeedableRng};
use aquatic::common::*;
use aquatic::config::Config;
mod announce;
@ -76,6 +77,7 @@ fn main(){
let mut rng = SmallRng::from_rng(thread_rng()).unwrap();
let info_hashes = create_info_hashes(&mut rng);
let config = Config::default();
let state_for_scrape: State = {
let requests = announce::create_requests(
@ -103,7 +105,7 @@ fn main(){
state.connections.insert(key, time);
}
let d = announce::bench(&state, requests.clone());
let d = announce::bench(&state, &config, requests.clone());
announce_data.0 += d.0;
announce_data.1 += d.1;