Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Stress Test #1935

Merged
merged 4 commits into from
Jul 16, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions stress/src/throughput.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ where
let worker_stats_shared_monitor = Arc::clone(&worker_stats_shared);

let handle_main_thread = thread::spawn(move || {
let mut start_time = Instant::now();
let mut end_time = start_time;
let mut last_collect_time = Instant::now();
let mut current_time: Instant;
let mut total_count_old: u64 = 0;

#[cfg(feature = "stats")]
Expand All @@ -79,12 +79,14 @@ where
let mut system = System::new_all();

loop {
let elapsed = end_time.duration_since(start_time).as_secs();
current_time = Instant::now();
let elapsed = current_time.duration_since(last_collect_time).as_secs();
if elapsed >= SLIDING_WINDOW_SIZE {
let total_count_u64: u64 = worker_stats_shared_monitor
.iter()
.map(|worker_stat| worker_stat.count.load(Ordering::Relaxed))
.sum();
last_collect_time = Instant::now();
let current_count = total_count_u64 - total_count_old;
total_count_old = total_count_u64;
let throughput = current_count / elapsed;
Expand Down Expand Up @@ -112,14 +114,12 @@ where
}

println!("\n");
start_time = Instant::now();
}

if STOP.load(Ordering::SeqCst) {
break;
}

end_time = Instant::now();
thread::sleep(Duration::from_millis(5000));
}
});
Expand Down
Loading