mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +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,
|
||||
/// Run duration (quit and generate report after this many seconds)
|
||||
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 handler: HandlerConfig,
|
||||
#[cfg(feature = "cpu-pinning")]
|
||||
|
|
@ -88,6 +91,7 @@ impl Default for Config {
|
|||
log_level: LogLevel::Error,
|
||||
workers: 1,
|
||||
duration: 0,
|
||||
additional_request_probability: 0.1,
|
||||
network: NetworkConfig::default(),
|
||||
handler: HandlerConfig::default(),
|
||||
#[cfg(feature = "cpu-pinning")]
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use std::sync::atomic::Ordering;
|
|||
use std::time::Duration;
|
||||
|
||||
use mio::{net::UdpSocket, Events, Interest, Poll, Token};
|
||||
use rand::Rng;
|
||||
use rand::{prelude::SmallRng, thread_rng, SeedableRng};
|
||||
use rand_distr::Pareto;
|
||||
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(
|
||||
&mut socket,
|
||||
&mut buffer,
|
||||
&mut statistics,
|
||||
additional_request,
|
||||
);
|
||||
send_request(
|
||||
&mut socket,
|
||||
&mut buffer,
|
||||
&mut statistics,
|
||||
additional_request,
|
||||
);
|
||||
}
|
||||
|
||||
update_shared_statistics(&state, &mut statistics);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue