mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 02:35:31 +00:00
udp load test: enable tuning additional request frequency
This commit is contained in:
parent
deac3898ef
commit
f6a33dac8a
2 changed files with 15 additions and 7 deletions
|
|
@ -18,6 +18,9 @@ pub struct Config {
|
||||||
pub workers: u8,
|
pub workers: u8,
|
||||||
/// Run duration (quit and generate report after this many seconds)
|
/// Run duration (quit and generate report after this many seconds)
|
||||||
pub duration: usize,
|
pub duration: usize,
|
||||||
|
/// Probability that an additional connect request will be sent for each
|
||||||
|
/// mio event
|
||||||
|
pub additional_request_probability: f32,
|
||||||
pub network: NetworkConfig,
|
pub network: NetworkConfig,
|
||||||
pub handler: HandlerConfig,
|
pub handler: HandlerConfig,
|
||||||
#[cfg(feature = "cpu-pinning")]
|
#[cfg(feature = "cpu-pinning")]
|
||||||
|
|
@ -88,6 +91,7 @@ impl Default for Config {
|
||||||
log_level: LogLevel::Error,
|
log_level: LogLevel::Error,
|
||||||
workers: 1,
|
workers: 1,
|
||||||
duration: 0,
|
duration: 0,
|
||||||
|
additional_request_probability: 0.1,
|
||||||
network: NetworkConfig::default(),
|
network: NetworkConfig::default(),
|
||||||
handler: HandlerConfig::default(),
|
handler: HandlerConfig::default(),
|
||||||
#[cfg(feature = "cpu-pinning")]
|
#[cfg(feature = "cpu-pinning")]
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ use std::sync::atomic::Ordering;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use mio::{net::UdpSocket, Events, Interest, Poll, Token};
|
use mio::{net::UdpSocket, Events, Interest, Poll, Token};
|
||||||
|
use rand::Rng;
|
||||||
use rand::{prelude::SmallRng, thread_rng, SeedableRng};
|
use rand::{prelude::SmallRng, thread_rng, SeedableRng};
|
||||||
use rand_distr::Pareto;
|
use rand_distr::Pareto;
|
||||||
use socket2::{Domain, Protocol, Socket, Type};
|
use socket2::{Domain, Protocol, Socket, Type};
|
||||||
|
|
@ -126,14 +127,17 @@ pub fn run_worker_thread(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let additional_request = create_connect_request(generate_transaction_id(&mut rng));
|
if rng.gen::<f32>() <= config.additional_request_probability {
|
||||||
|
let additional_request =
|
||||||
|
create_connect_request(generate_transaction_id(&mut rng));
|
||||||
|
|
||||||
send_request(
|
send_request(
|
||||||
&mut socket,
|
&mut socket,
|
||||||
&mut buffer,
|
&mut buffer,
|
||||||
&mut statistics,
|
&mut statistics,
|
||||||
additional_request,
|
additional_request,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
update_shared_statistics(&state, &mut statistics);
|
update_shared_statistics(&state, &mut statistics);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue