mirror of
https://github.com/greatest-ape/aquatic.git
synced 2026-09-17 08:24:20 +00:00
ws load test: add config field for connection creation interval
This commit is contained in:
@@ -18,6 +18,7 @@ pub struct Config {
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[serde(default)]
|
||||
pub struct NetworkConfig {
|
||||
pub connection_creation_interval: usize,
|
||||
pub poll_timeout_microseconds: u64,
|
||||
pub poll_event_capacity: usize,
|
||||
}
|
||||
@@ -58,6 +59,7 @@ impl Default for Config {
|
||||
impl Default for NetworkConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
connection_creation_interval: 40,
|
||||
poll_timeout_microseconds: 1000,
|
||||
poll_event_capacity: 4096,
|
||||
}
|
||||
|
||||
@@ -241,15 +241,13 @@ impl Connection {
|
||||
pub type ConnectionMap = HashMap<usize, Connection>;
|
||||
|
||||
|
||||
const CREATE_CONN_INTERVAL: usize = 2 ^ 30;
|
||||
|
||||
|
||||
pub fn run_socket_thread(
|
||||
config: &Config,
|
||||
state: LoadTestState,
|
||||
num_initial_requests: usize,
|
||||
) {
|
||||
let timeout = Duration::from_micros(config.network.poll_timeout_microseconds);
|
||||
let create_conn_interval = 2 ^ config.network.connection_creation_interval;
|
||||
|
||||
let mut connections: ConnectionMap = HashMap::with_capacity(config.num_connections);
|
||||
let mut poll = Poll::new().expect("create poll");
|
||||
@@ -351,7 +349,7 @@ pub fn run_socket_thread(
|
||||
}
|
||||
|
||||
// Slowly create new connections
|
||||
if token_counter < config.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,
|
||||
|
||||
Reference in New Issue
Block a user