diff --git a/rawhammer/src/main.rs b/rawhammer/src/main.rs index 354ce65..463b2bc 100644 --- a/rawhammer/src/main.rs +++ b/rawhammer/src/main.rs @@ -1,6 +1,6 @@ use std::io::Write; use std::net::*; -use std::time::Duration; +use std::time::{Duration, Instant}; use std::thread; use std::time; use clap::{Arg, App}; @@ -194,7 +194,6 @@ fn sleep(micros: u64, cmt: &'static str) { } fn sleep_no_comment(micros: u64) { - println!("micros {}", micros); if micros > 0 { let dur_micros = time::Duration::from_micros(micros); thread::sleep(dur_micros); @@ -257,12 +256,14 @@ fn main() -> std::io::Result<()> { // Start a thread which sends CH let mut threads = Vec::new(); + // report every 1000 msgs sent + let msg_nb_report = 1000; for _ in 0..sending_threads { // Condition variables to control threads let t = thread::spawn(move || { // calculates number of sent client hellos let mut ch_sent = 0; - + let mut now = Instant::now(); loop { // try connect let sock = TcpStream::connect_timeout(&sock_addr, dur); @@ -281,8 +282,13 @@ fn main() -> std::io::Result<()> { s.shutdown(Shutdown::Both).expect("shutdown call failed"); sleep_no_comment(1000000/msg_per_sec as u64); ch_sent += 1; - if ch_sent % 100 == 0 { - println!("nb of queries sent: {}", ch_sent); + if ch_sent % msg_nb_report == 0 { + println!("nb of queries sent: total: {}. {1} msg's in {2} sec. {3} per sec", + ch_sent, + msg_nb_report, + now.elapsed().as_millis() as f64/1000 as f64, + ((msg_nb_report as f64 / now.elapsed().as_millis() as f64) * 1000 as f64) as i64); + now = Instant::now(); } } });