Skip to content

Commit

Permalink
Merge pull request #1454 from microsoft/bugfix-testing-echo
Browse files Browse the repository at this point in the history
[testing] Bug Fix: Correctly exit
  • Loading branch information
iyzhang authored Nov 8, 2024
2 parents e0cb130 + 534d424 commit 6019bb6
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions examples/tcp-echo/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub struct TcpEchoClient {
libos: LibOS,
/// Buffer size.
bufsize: usize,
/// Number of packets echoed back.
/// Number of packets echoed back since last log period.
nechoed: usize,
/// Number of bytes transferred.
nbytes: usize,
Expand Down Expand Up @@ -131,17 +131,16 @@ impl TcpEchoClient {
if let Some(log_interval) = log_interval {
if last_log.elapsed() > Duration::from_secs(log_interval) {
let time_elapsed: f64 = (Instant::now() - last_log).as_secs() as f64;
let nrequests: f64 = (self.nbytes / self.bufsize) as f64;
let rps: f64 = nrequests / time_elapsed;
let rps: f64 = self.nechoed as f64 / time_elapsed;
println!(
"INFO: {:?} requests, {:2?} rps, p50 {:?} ns, p99 {:?} ns",
nrequests,
self.nechoed,
rps,
self.stats.percentile(0.50)?.unwrap().start(),
self.stats.percentile(0.99)?.unwrap().start(),
);
last_log = Instant::now();
self.nbytes = 0;
self.nechoed = 0;
}
}

Expand Down Expand Up @@ -230,17 +229,16 @@ impl TcpEchoClient {
if let Some(log_interval) = log_interval {
if last_log.elapsed() > Duration::from_secs(log_interval) {
let time_elapsed: f64 = (Instant::now() - last_log).as_secs() as f64;
let nrequests: f64 = (self.nbytes / self.bufsize) as f64;
let rps: f64 = nrequests / time_elapsed;
let rps: f64 = self.nechoed as f64 / time_elapsed;
println!(
"INFO: {:?} requests, {:2?} rps, p50 {:?} ns, p99 {:?} ns",
nrequests,
self.nechoed,
rps,
self.stats.percentile(0.50)?.unwrap().start(),
self.stats.percentile(0.99)?.unwrap().start(),
);
last_log = Instant::now();
self.nbytes = 0;
self.nechoed = 0;
}
}

Expand Down

0 comments on commit 6019bb6

Please sign in to comment.