diff --git a/bench-tps/src/bench.rs b/bench-tps/src/bench.rs index 6dc44ed1f..0842fa02c 100644 --- a/bench-tps/src/bench.rs +++ b/bench-tps/src/bench.rs @@ -233,9 +233,13 @@ pub fn do_tx_transfers( leader: &NodeInfo, shared_tx_thread_count: &Arc, total_tx_sent_count: &Arc, + thread_batch_sleep_ms: usize, ) { let client = mk_client(&leader); loop { + if thread_batch_sleep_ms > 0 { + sleep(Duration::from_millis(thread_batch_sleep_ms as u64)); + } let txs; { let mut shared_txs_wl = shared_txs.write().unwrap(); diff --git a/bench-tps/src/cli.rs b/bench-tps/src/cli.rs index 23c87d624..e9e1fb73d 100644 --- a/bench-tps/src/cli.rs +++ b/bench-tps/src/cli.rs @@ -15,6 +15,7 @@ pub struct Config { pub num_nodes: usize, pub duration: Duration, pub tx_count: usize, + pub thread_batch_sleep_ms: usize, pub sustained: bool, pub reject_extra_nodes: bool, pub converge_only: bool, @@ -30,6 +31,7 @@ impl Default for Config { num_nodes: 1, duration: Duration::new(std::u64::MAX, 0), tx_count: 500_000, + thread_batch_sleep_ms: 0, sustained: false, reject_extra_nodes: false, converge_only: false, @@ -110,6 +112,14 @@ pub fn build_args<'a, 'b>() -> App<'a, 'b> { .takes_value(true) .help("Number of transactions to send per batch") ) + .arg( + Arg::with_name("thread-batch-sleep-ms") + .short("z") + .long("thread-batch-sleep-ms") + .value_name("NUM") + .takes_value(true) + .help("Per-thread-per-iteration sleep in ms"), + ) } /// Parses a clap `ArgMatches` structure into a `Config` @@ -158,6 +168,13 @@ pub fn extract_args<'a>(matches: &ArgMatches<'a>) -> Config { args.tx_count = s.to_string().parse().expect("can't parse tx_account"); } + if let Some(t) = matches.value_of("thread-batch-sleep-ms") { + args.thread_batch_sleep_ms = t + .to_string() + .parse() + .expect("can't parse thread-batch-sleep-ms"); + } + args.sustained = matches.is_present("sustained"); args.converge_only = matches.is_present("converge-only"); args.reject_extra_nodes = matches.is_present("reject-extra-nodes"); diff --git a/bench-tps/src/main.rs b/bench-tps/src/main.rs index eb3be6de0..e6fef1298 100644 --- a/bench-tps/src/main.rs +++ b/bench-tps/src/main.rs @@ -82,6 +82,7 @@ fn main() { drone_addr, id, threads, + thread_batch_sleep_ms, num_nodes, duration, tx_count, @@ -207,6 +208,7 @@ fn main() { &leader, &shared_tx_active_thread_count, &total_tx_sent_count, + thread_batch_sleep_ms, ); }) .unwrap()