Client concurrency option
This commit is contained in:
parent
7c7414cf93
commit
976ffc062e
2 changed files with 6 additions and 1 deletions
|
|
@ -96,11 +96,12 @@ pub async fn play(
|
||||||
repeat: u32,
|
repeat: u32,
|
||||||
cert_path: Option<&str>,
|
cert_path: Option<&str>,
|
||||||
skip_verif: bool,
|
skip_verif: bool,
|
||||||
|
concurrency: usize,
|
||||||
debug: bool,
|
debug: bool,
|
||||||
) {
|
) {
|
||||||
// Semaphore used to limit the number of concurrent clients.
|
// Semaphore used to limit the number of concurrent clients.
|
||||||
// Its handle is released when the task panics.
|
// Its handle is released when the task panics.
|
||||||
let limiter = Arc::new(Semaphore::new(16));
|
let limiter = Arc::new(Semaphore::new(concurrency));
|
||||||
let counter = Arc::new(AtomicU32::new(0));
|
let counter = Arc::new(AtomicU32::new(0));
|
||||||
let running = Arc::new(Mutex::new(HashSet::new()));
|
let running = Arc::new(Mutex::new(HashSet::new()));
|
||||||
let total = records.len() * repeat as usize;
|
let total = records.len() * repeat as usize;
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,9 @@ struct OptClient {
|
||||||
/// Do not verify certificates
|
/// Do not verify certificates
|
||||||
#[argp(switch, short = 's')]
|
#[argp(switch, short = 's')]
|
||||||
skip_verif: bool,
|
skip_verif: bool,
|
||||||
|
/// Maximum number of concurrent clients
|
||||||
|
#[argp(option, default = "16")]
|
||||||
|
concurrency: usize,
|
||||||
/// Print debug info
|
/// Print debug info
|
||||||
#[argp(switch, short = 'd')]
|
#[argp(switch, short = 'd')]
|
||||||
debug: bool,
|
debug: bool,
|
||||||
|
|
@ -150,6 +153,7 @@ async fn main() {
|
||||||
subopt.repeat,
|
subopt.repeat,
|
||||||
subopt.certs.as_deref(),
|
subopt.certs.as_deref(),
|
||||||
subopt.skip_verif,
|
subopt.skip_verif,
|
||||||
|
subopt.concurrency,
|
||||||
subopt.debug,
|
subopt.debug,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue