diff --git a/aquatic_ws_load_test/src/config.rs b/aquatic_ws_load_test/src/config.rs index 84b92d1..c78818b 100644 --- a/aquatic_ws_load_test/src/config.rs +++ b/aquatic_ws_load_test/src/config.rs @@ -8,6 +8,7 @@ use serde::{Serialize, Deserialize}; pub struct Config { pub server_address: SocketAddr, pub num_workers: u8, + pub num_connections: usize, pub duration: usize, pub network: NetworkConfig, pub torrents: TorrentConfig, @@ -46,6 +47,7 @@ impl Default for Config { Self { server_address: "127.0.0.1:3000".parse().unwrap(), num_workers: 1, + num_connections: 8, duration: 0, network: NetworkConfig::default(), torrents: TorrentConfig::default(), diff --git a/aquatic_ws_load_test/src/network.rs b/aquatic_ws_load_test/src/network.rs index 07fe203..e7d4167 100644 --- a/aquatic_ws_load_test/src/network.rs +++ b/aquatic_ws_load_test/src/network.rs @@ -204,7 +204,6 @@ impl Connection { pub type ConnectionMap = HashMap; -const NUM_CONNECTIONS: usize = 5; const CREATE_CONN_INTERVAL: usize = 2 ^ 30; @@ -215,7 +214,7 @@ pub fn run_socket_thread( ) { let timeout = Duration::from_micros(config.network.poll_timeout_microseconds); - let mut connections: ConnectionMap = HashMap::with_capacity(NUM_CONNECTIONS); + let mut connections: ConnectionMap = HashMap::with_capacity(config.num_connections); let mut poll = Poll::new().expect("create poll"); let mut events = Events::with_capacity(config.network.poll_event_capacity); let mut rng = SmallRng::from_entropy(); @@ -315,7 +314,7 @@ pub fn run_socket_thread( } // Slowly create new connections - if token_counter < NUM_CONNECTIONS && iter_counter % CREATE_CONN_INTERVAL == 0 { + if token_counter < config.num_connections && iter_counter % CREATE_CONN_INTERVAL == 0 { let res = Connection::create_and_register( config, &mut connections,