Add max number of msgs to send

This commit is contained in:
Henry Case 2019-07-28 23:35:35 +01:00
parent e88942f680
commit e45a7687ea

View File

@ -240,6 +240,12 @@ fn main() -> std::io::Result<()> {
.takes_value(true)
.required(false)
.help("Number of sending threads (default 1)"))
.arg(Arg::with_name("maxmsg")
.short("m")
.long("max_messages")
.takes_value(true)
.required(false)
.help("Max number of messages to send (default infinity)"))
.get_matches();
let sock_addr: SocketAddr = matches
@ -255,6 +261,8 @@ fn main() -> std::io::Result<()> {
.value_of("case").unwrap().parse().unwrap();
let sending_threads: usize = matches
.value_of("threads").unwrap_or("1").parse().unwrap();
let max_msg: usize = matches
.value_of("maxmsg").unwrap_or("0").parse().unwrap();
println!("Sending to {0}, with freq {1} per sec on {2} threads.",
sock_addr, msg_per_sec, sending_threads);
@ -297,6 +305,9 @@ fn main() -> std::io::Result<()> {
((msg_nb_report as f64 / now.elapsed().as_millis() as f64) * 1000 as f64) as i64);
now = Instant::now();
}
if max_msg!=0 && max_msg <= ch_sent {
break;
}
}
});
threads.push(t);