mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 10:45:30 +00:00
aquatic ws load test: make NUM_CONNECTIONS a config field
This commit is contained in:
parent
55045279ac
commit
364606a025
2 changed files with 4 additions and 3 deletions
|
|
@ -8,6 +8,7 @@ use serde::{Serialize, Deserialize};
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
pub server_address: SocketAddr,
|
pub server_address: SocketAddr,
|
||||||
pub num_workers: u8,
|
pub num_workers: u8,
|
||||||
|
pub num_connections: usize,
|
||||||
pub duration: usize,
|
pub duration: usize,
|
||||||
pub network: NetworkConfig,
|
pub network: NetworkConfig,
|
||||||
pub torrents: TorrentConfig,
|
pub torrents: TorrentConfig,
|
||||||
|
|
@ -46,6 +47,7 @@ impl Default for Config {
|
||||||
Self {
|
Self {
|
||||||
server_address: "127.0.0.1:3000".parse().unwrap(),
|
server_address: "127.0.0.1:3000".parse().unwrap(),
|
||||||
num_workers: 1,
|
num_workers: 1,
|
||||||
|
num_connections: 8,
|
||||||
duration: 0,
|
duration: 0,
|
||||||
network: NetworkConfig::default(),
|
network: NetworkConfig::default(),
|
||||||
torrents: TorrentConfig::default(),
|
torrents: TorrentConfig::default(),
|
||||||
|
|
|
||||||
|
|
@ -204,7 +204,6 @@ impl Connection {
|
||||||
pub type ConnectionMap = HashMap<usize, Connection>;
|
pub type ConnectionMap = HashMap<usize, Connection>;
|
||||||
|
|
||||||
|
|
||||||
const NUM_CONNECTIONS: usize = 5;
|
|
||||||
const CREATE_CONN_INTERVAL: usize = 2 ^ 30;
|
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 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 poll = Poll::new().expect("create poll");
|
||||||
let mut events = Events::with_capacity(config.network.poll_event_capacity);
|
let mut events = Events::with_capacity(config.network.poll_event_capacity);
|
||||||
let mut rng = SmallRng::from_entropy();
|
let mut rng = SmallRng::from_entropy();
|
||||||
|
|
@ -315,7 +314,7 @@ pub fn run_socket_thread(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Slowly create new connections
|
// 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(
|
let res = Connection::create_and_register(
|
||||||
config,
|
config,
|
||||||
&mut connections,
|
&mut connections,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue