Browse Source

Add max number of msgs to send

master
Henry Case 5 years ago
parent
commit
e45a7687ea
1 changed files with 11 additions and 0 deletions
  1. +11
    -0
      rawhammer/src/main.rs

+ 11
- 0
rawhammer/src/main.rs View File

@@ -240,6 +240,12 @@ fn main() -> std::io::Result<()> {
.takes_value(true) .takes_value(true)
.required(false) .required(false)
.help("Number of sending threads (default 1)")) .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(); .get_matches();


let sock_addr: SocketAddr = matches let sock_addr: SocketAddr = matches
@@ -255,6 +261,8 @@ fn main() -> std::io::Result<()> {
.value_of("case").unwrap().parse().unwrap(); .value_of("case").unwrap().parse().unwrap();
let sending_threads: usize = matches let sending_threads: usize = matches
.value_of("threads").unwrap_or("1").parse().unwrap(); .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.", println!("Sending to {0}, with freq {1} per sec on {2} threads.",
sock_addr, msg_per_sec, sending_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); ((msg_nb_report as f64 / now.elapsed().as_millis() as f64) * 1000 as f64) as i64);
now = Instant::now(); now = Instant::now();
} }
if max_msg!=0 && max_msg <= ch_sent {
break;
}
} }
}); });
threads.push(t); threads.push(t);


Loading…
Cancel
Save