Skip to content

Commit 6f3c18d

Browse files
committed
Fix Stress Test
1 parent 5922205 commit 6f3c18d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

stress/src/throughput.rs

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

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

7676
#[cfg(feature = "stats")]
@@ -79,7 +79,8 @@ where
7979
let mut system = System::new_all();
8080

8181
loop {
82-
let elapsed = end_time.duration_since(start_time).as_secs();
82+
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
8384
if elapsed >= SLIDING_WINDOW_SIZE {
8485
let total_count_u64: u64 = worker_stats_shared_monitor
8586
.iter()
@@ -112,14 +113,13 @@ where
112113
}
113114

114115
println!("\n");
115-
start_time = Instant::now();
116+
last_run = Instant::now();
116117
}
117118

118119
if STOP.load(Ordering::SeqCst) {
119120
break;
120121
}
121122

122-
end_time = Instant::now();
123123
thread::sleep(Duration::from_millis(5000));
124124
}
125125
});

0 commit comments

Comments
 (0)