Skip to content

Commit 9bc60e9

Browse files
committed
Code changes
1 parent 6f3c18d commit 9bc60e9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

stress/src/throughput.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ where
6969
let worker_stats_shared_monitor = Arc::clone(&worker_stats_shared);
7070

7171
let handle_main_thread = thread::spawn(move || {
72-
let mut last_run = Instant::now();
72+
let mut last_collect_time = Instant::now();
7373
let mut current_time: Instant;
7474
let mut total_count_old: u64 = 0;
7575

@@ -80,12 +80,13 @@ where
8080

8181
loop {
8282
current_time = Instant::now();
83-
let elapsed = current_time.duration_since(last_run).as_secs(); // Calculate the time elapsed (in seconds) since the last collect
83+
let elapsed = current_time.duration_since(last_collect_time).as_secs();
8484
if elapsed >= SLIDING_WINDOW_SIZE {
8585
let total_count_u64: u64 = worker_stats_shared_monitor
8686
.iter()
8787
.map(|worker_stat| worker_stat.count.load(Ordering::Relaxed))
8888
.sum();
89+
last_collect_time = Instant::now();
8990
let current_count = total_count_u64 - total_count_old;
9091
total_count_old = total_count_u64;
9192
let throughput = current_count / elapsed;
@@ -113,7 +114,6 @@ where
113114
}
114115

115116
println!("\n");
116-
last_run = Instant::now();
117117
}
118118

119119
if STOP.load(Ordering::SeqCst) {

0 commit comments

Comments
 (0)