mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 09:45:31 +00:00
ws load test: add config field for connection creation interval
This commit is contained in:
parent
aa0094164a
commit
f561ca9794
2 changed files with 4 additions and 4 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue