mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +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)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub struct NetworkConfig {
|
pub struct NetworkConfig {
|
||||||
|
pub connection_creation_interval: usize,
|
||||||
pub poll_timeout_microseconds: u64,
|
pub poll_timeout_microseconds: u64,
|
||||||
pub poll_event_capacity: usize,
|
pub poll_event_capacity: usize,
|
||||||
}
|
}
|
||||||
|
|
@ -58,6 +59,7 @@ impl Default for Config {
|
||||||
impl Default for NetworkConfig {
|
impl Default for NetworkConfig {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
connection_creation_interval: 40,
|
||||||
poll_timeout_microseconds: 1000,
|
poll_timeout_microseconds: 1000,
|
||||||
poll_event_capacity: 4096,
|
poll_event_capacity: 4096,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -241,15 +241,13 @@ impl Connection {
|
||||||
pub type ConnectionMap = HashMap<usize, Connection>;
|
pub type ConnectionMap = HashMap<usize, Connection>;
|
||||||
|
|
||||||
|
|
||||||
const CREATE_CONN_INTERVAL: usize = 2 ^ 30;
|
|
||||||
|
|
||||||
|
|
||||||
pub fn run_socket_thread(
|
pub fn run_socket_thread(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
state: LoadTestState,
|
state: LoadTestState,
|
||||||
num_initial_requests: usize,
|
num_initial_requests: usize,
|
||||||
) {
|
) {
|
||||||
let timeout = Duration::from_micros(config.network.poll_timeout_microseconds);
|
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 connections: ConnectionMap = HashMap::with_capacity(config.num_connections);
|
||||||
let mut poll = Poll::new().expect("create poll");
|
let mut poll = Poll::new().expect("create poll");
|
||||||
|
|
@ -351,7 +349,7 @@ pub fn run_socket_thread(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Slowly create new connections
|
// 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(
|
let res = Connection::create_and_register(
|
||||||
config,
|
config,
|
||||||
&mut connections,
|
&mut connections,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue