mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 10:45:30 +00:00
udp load test: improve statistics code
This commit is contained in:
parent
b70cbe6349
commit
6605055b3d
1 changed files with 27 additions and 27 deletions
|
|
@ -115,7 +115,7 @@ fn monitor_statistics(state: LoadTestState, config: &Config) {
|
||||||
|
|
||||||
let mut last = start_time;
|
let mut last = start_time;
|
||||||
|
|
||||||
loop {
|
let time_elapsed = loop {
|
||||||
thread::sleep(Duration::from_secs(interval));
|
thread::sleep(Duration::from_secs(interval));
|
||||||
|
|
||||||
let requests = fetch_and_reset(&state.statistics.requests);
|
let requests = fetch_and_reset(&state.statistics.requests);
|
||||||
|
|
@ -164,6 +164,10 @@ fn monitor_statistics(state: LoadTestState, config: &Config) {
|
||||||
let time_elapsed = start_time.elapsed();
|
let time_elapsed = start_time.elapsed();
|
||||||
|
|
||||||
if config.duration != 0 && time_elapsed >= duration {
|
if config.duration != 0 && time_elapsed >= duration {
|
||||||
|
break time_elapsed;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let len = report_avg_connect.len() as f64;
|
let len = report_avg_connect.len() as f64;
|
||||||
|
|
||||||
let avg_connect: f64 = report_avg_connect.into_iter().sum::<f64>() / len;
|
let avg_connect: f64 = report_avg_connect.into_iter().sum::<f64>() / len;
|
||||||
|
|
@ -187,10 +191,6 @@ fn monitor_statistics(state: LoadTestState, config: &Config) {
|
||||||
println!(" - Announce responses: {:.2}", avg_announce);
|
println!(" - Announce responses: {:.2}", avg_announce);
|
||||||
println!(" - Scrape responses: {:.2}", avg_scrape);
|
println!(" - Scrape responses: {:.2}", avg_scrape);
|
||||||
println!(" - Error responses: {:.2}", avg_error);
|
println!(" - Error responses: {:.2}", avg_error);
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fetch_and_reset(atomic_usize: &AtomicUsize) -> f64 {
|
fn fetch_and_reset(atomic_usize: &AtomicUsize) -> f64 {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue