cargo fmt

This commit is contained in:
Ian Goldberg 2022-10-20 11:34:39 -04:00
parent 4b983c52c1
commit fb93fddcf2
1 changed files with 95 additions and 55 deletions

View File

@ -4,7 +4,7 @@ BridgeLine::random() or private fields */
use super::bridge_table::BridgeLine; use super::bridge_table::BridgeLine;
use super::proto::*; use super::proto::*;
use super::*; use super::*;
use chrono::{Utc, DateTime, NaiveTime, Timelike}; use chrono::{DateTime, NaiveTime, Timelike, Utc};
use rand::Rng; use rand::Rng;
use statistical::{mean, standard_deviation}; use statistical::{mean, standard_deviation};
use std::collections::HashSet; use std::collections::HashSet;
@ -760,7 +760,7 @@ fn stats_test_trust_levels() {
let h: NaiveTime = DateTime::time(&Utc::now()); let h: NaiveTime = DateTime::time(&Utc::now());
if h.hour() == 23 && h.minute() == 59 { if h.hour() == 23 && h.minute() == 59 {
println!("Wait for UTC 00:00"); println!("Wait for UTC 00:00");
thread::sleep(Duration::new(60,0)); thread::sleep(Duration::new(60, 0));
println!("Ready to work again"); println!("Ready to work again");
} }
let (open_perf_stat, cred) = th.open_invite(); let (open_perf_stat, cred) = th.open_invite();
@ -884,7 +884,7 @@ fn stats_test_invitations() {
if h.hour() == 23 && h.minute() == 59 { if h.hour() == 23 && h.minute() == 59 {
println!("Wait for UTC 00:00"); println!("Wait for UTC 00:00");
thread::sleep(Duration::new(60,0)); thread::sleep(Duration::new(60, 0));
println!("Ready to work again"); println!("Ready to work again");
} }
let cred = th.open_invite().1 .0; let cred = th.open_invite().1 .0;
@ -934,7 +934,7 @@ fn stats_test_percent_blockage_migration_05() {
let h: NaiveTime = DateTime::time(&Utc::now()); let h: NaiveTime = DateTime::time(&Utc::now());
if h.hour() == 23 && h.minute() == 59 { if h.hour() == 23 && h.minute() == 59 {
println!("Wait for UTC 00:00"); println!("Wait for UTC 00:00");
thread::sleep(Duration::new(60,0)); thread::sleep(Duration::new(60, 0));
println!("Ready to work again"); println!("Ready to work again");
} }
let cred = th.open_invite().1 .0; let cred = th.open_invite().1 .0;
@ -967,7 +967,7 @@ fn stats_test_percent_blockage_migration_010() {
let h: NaiveTime = DateTime::time(&Utc::now()); let h: NaiveTime = DateTime::time(&Utc::now());
if h.hour() == 23 && h.minute() == 59 { if h.hour() == 23 && h.minute() == 59 {
println!("Wait for UTC 00:00"); println!("Wait for UTC 00:00");
thread::sleep(Duration::new(60,0)); thread::sleep(Duration::new(60, 0));
println!("Ready to work again"); println!("Ready to work again");
} }
let cred = th.open_invite().1 .0; let cred = th.open_invite().1 .0;
@ -1000,7 +1000,7 @@ fn stats_test_percent_blockage_migration_15() {
let h: NaiveTime = DateTime::time(&Utc::now()); let h: NaiveTime = DateTime::time(&Utc::now());
if h.hour() == 23 && h.minute() == 59 { if h.hour() == 23 && h.minute() == 59 {
println!("Wait for UTC 00:00"); println!("Wait for UTC 00:00");
thread::sleep(Duration::new(60,0)); thread::sleep(Duration::new(60, 0));
println!("Ready to work again"); println!("Ready to work again");
} }
let cred = th.open_invite().1 .0; let cred = th.open_invite().1 .0;
@ -1033,7 +1033,7 @@ fn stats_test_percent_blockage_migration_20() {
let h: NaiveTime = DateTime::time(&Utc::now()); let h: NaiveTime = DateTime::time(&Utc::now());
if h.hour() == 23 && h.minute() == 59 { if h.hour() == 23 && h.minute() == 59 {
println!("Wait for UTC 00:00"); println!("Wait for UTC 00:00");
thread::sleep(Duration::new(60,0)); thread::sleep(Duration::new(60, 0));
println!("Ready to work again"); println!("Ready to work again");
} }
let cred = th.open_invite().1 .0; let cred = th.open_invite().1 .0;
@ -1066,7 +1066,7 @@ fn stats_test_percent_blockage_migration_25() {
let h: NaiveTime = DateTime::time(&Utc::now()); let h: NaiveTime = DateTime::time(&Utc::now());
if h.hour() == 23 && h.minute() == 59 { if h.hour() == 23 && h.minute() == 59 {
println!("Wait for UTC 00:00"); println!("Wait for UTC 00:00");
thread::sleep(Duration::new(60,0)); thread::sleep(Duration::new(60, 0));
println!("Ready to work again"); println!("Ready to work again");
} }
let cred = th.open_invite().1 .0; let cred = th.open_invite().1 .0;
@ -1099,7 +1099,7 @@ fn stats_test_percent_blockage_migration_30() {
let h: NaiveTime = DateTime::time(&Utc::now()); let h: NaiveTime = DateTime::time(&Utc::now());
if h.hour() == 23 && h.minute() == 59 { if h.hour() == 23 && h.minute() == 59 {
println!("Wait for UTC 00:00"); println!("Wait for UTC 00:00");
thread::sleep(Duration::new(60,0)); thread::sleep(Duration::new(60, 0));
println!("Ready to work again"); println!("Ready to work again");
} }
let cred = th.open_invite().1 .0; let cred = th.open_invite().1 .0;
@ -1132,7 +1132,7 @@ fn stats_test_percent_blockage_migration_35() {
let h: NaiveTime = DateTime::time(&Utc::now()); let h: NaiveTime = DateTime::time(&Utc::now());
if h.hour() == 23 && h.minute() == 59 { if h.hour() == 23 && h.minute() == 59 {
println!("Wait for UTC 00:00"); println!("Wait for UTC 00:00");
thread::sleep(Duration::new(60,0)); thread::sleep(Duration::new(60, 0));
println!("Ready to work again"); println!("Ready to work again");
} }
let cred = th.open_invite().1 .0; let cred = th.open_invite().1 .0;
@ -1165,7 +1165,7 @@ fn stats_test_percent_blockage_migration_40() {
let h: NaiveTime = DateTime::time(&Utc::now()); let h: NaiveTime = DateTime::time(&Utc::now());
if h.hour() == 23 && h.minute() == 59 { if h.hour() == 23 && h.minute() == 59 {
println!("Wait for UTC 00:00"); println!("Wait for UTC 00:00");
thread::sleep(Duration::new(60,0)); thread::sleep(Duration::new(60, 0));
println!("Ready to work again"); println!("Ready to work again");
} }
let cred = th.open_invite().1 .0; let cred = th.open_invite().1 .0;
@ -1198,7 +1198,7 @@ fn stats_test_percent_blockage_migration_45() {
let h: NaiveTime = DateTime::time(&Utc::now()); let h: NaiveTime = DateTime::time(&Utc::now());
if h.hour() == 23 && h.minute() == 59 { if h.hour() == 23 && h.minute() == 59 {
println!("Wait for UTC 00:00"); println!("Wait for UTC 00:00");
thread::sleep(Duration::new(60,0)); thread::sleep(Duration::new(60, 0));
println!("Ready to work again"); println!("Ready to work again");
} }
let cred = th.open_invite().1 .0; let cred = th.open_invite().1 .0;
@ -1231,7 +1231,7 @@ fn stats_test_percent_blockage_migration_50() {
let h: NaiveTime = DateTime::time(&Utc::now()); let h: NaiveTime = DateTime::time(&Utc::now());
if h.hour() == 23 && h.minute() == 59 { if h.hour() == 23 && h.minute() == 59 {
println!("Wait for UTC 00:00"); println!("Wait for UTC 00:00");
thread::sleep(Duration::new(60,0)); thread::sleep(Duration::new(60, 0));
println!("Ready to work again"); println!("Ready to work again");
} }
let cred = th.open_invite().1 .0; let cred = th.open_invite().1 .0;
@ -1264,7 +1264,7 @@ fn stats_test_percent_blockage_migration_55() {
let h: NaiveTime = DateTime::time(&Utc::now()); let h: NaiveTime = DateTime::time(&Utc::now());
if h.hour() == 23 && h.minute() == 59 { if h.hour() == 23 && h.minute() == 59 {
println!("Wait for UTC 00:00"); println!("Wait for UTC 00:00");
thread::sleep(Duration::new(60,0)); thread::sleep(Duration::new(60, 0));
println!("Ready to work again"); println!("Ready to work again");
} }
let cred = th.open_invite().1 .0; let cred = th.open_invite().1 .0;
@ -1297,7 +1297,7 @@ fn stats_test_percent_blockage_migration_60() {
let h: NaiveTime = DateTime::time(&Utc::now()); let h: NaiveTime = DateTime::time(&Utc::now());
if h.hour() == 23 && h.minute() == 59 { if h.hour() == 23 && h.minute() == 59 {
println!("Wait for UTC 00:00"); println!("Wait for UTC 00:00");
thread::sleep(Duration::new(60,0)); thread::sleep(Duration::new(60, 0));
println!("Ready to work again"); println!("Ready to work again");
} }
let cred = th.open_invite().1 .0; let cred = th.open_invite().1 .0;
@ -1330,7 +1330,7 @@ fn stats_test_percent_blockage_migration_65() {
let h: NaiveTime = DateTime::time(&Utc::now()); let h: NaiveTime = DateTime::time(&Utc::now());
if h.hour() == 23 && h.minute() == 59 { if h.hour() == 23 && h.minute() == 59 {
println!("Wait for UTC 00:00"); println!("Wait for UTC 00:00");
thread::sleep(Duration::new(60,0)); thread::sleep(Duration::new(60, 0));
println!("Ready to work again"); println!("Ready to work again");
} }
let cred = th.open_invite().1 .0; let cred = th.open_invite().1 .0;
@ -1363,7 +1363,7 @@ fn stats_test_percent_blockage_migration_70() {
let h: NaiveTime = DateTime::time(&Utc::now()); let h: NaiveTime = DateTime::time(&Utc::now());
if h.hour() == 23 && h.minute() == 59 { if h.hour() == 23 && h.minute() == 59 {
println!("Wait for UTC 00:00"); println!("Wait for UTC 00:00");
thread::sleep(Duration::new(60,0)); thread::sleep(Duration::new(60, 0));
println!("Ready to work again"); println!("Ready to work again");
} }
let cred = th.open_invite().1 .0; let cred = th.open_invite().1 .0;
@ -1396,7 +1396,7 @@ fn stats_test_percent_blockage_migration_75() {
let h: NaiveTime = DateTime::time(&Utc::now()); let h: NaiveTime = DateTime::time(&Utc::now());
if h.hour() == 23 && h.minute() == 59 { if h.hour() == 23 && h.minute() == 59 {
println!("Wait for UTC 00:00"); println!("Wait for UTC 00:00");
thread::sleep(Duration::new(60,0)); thread::sleep(Duration::new(60, 0));
println!("Ready to work again"); println!("Ready to work again");
} }
let cred = th.open_invite().1 .0; let cred = th.open_invite().1 .0;
@ -1429,7 +1429,7 @@ fn stats_test_percent_blockage_migration_80() {
let h: NaiveTime = DateTime::time(&Utc::now()); let h: NaiveTime = DateTime::time(&Utc::now());
if h.hour() == 23 && h.minute() == 59 { if h.hour() == 23 && h.minute() == 59 {
println!("Wait for UTC 00:00"); println!("Wait for UTC 00:00");
thread::sleep(Duration::new(60,0)); thread::sleep(Duration::new(60, 0));
println!("Ready to work again"); println!("Ready to work again");
} }
let cred = th.open_invite().1 .0; let cred = th.open_invite().1 .0;
@ -1462,7 +1462,7 @@ fn stats_test_percent_blockage_migration_85() {
let h: NaiveTime = DateTime::time(&Utc::now()); let h: NaiveTime = DateTime::time(&Utc::now());
if h.hour() == 23 && h.minute() == 59 { if h.hour() == 23 && h.minute() == 59 {
println!("Wait for UTC 00:00"); println!("Wait for UTC 00:00");
thread::sleep(Duration::new(60,0)); thread::sleep(Duration::new(60, 0));
println!("Ready to work again"); println!("Ready to work again");
} }
let cred = th.open_invite().1 .0; let cred = th.open_invite().1 .0;
@ -1495,7 +1495,7 @@ fn stats_test_percent_blockage_migration_90() {
let h: NaiveTime = DateTime::time(&Utc::now()); let h: NaiveTime = DateTime::time(&Utc::now());
if h.hour() == 23 && h.minute() == 59 { if h.hour() == 23 && h.minute() == 59 {
println!("Wait for UTC 00:00"); println!("Wait for UTC 00:00");
thread::sleep(Duration::new(60,0)); thread::sleep(Duration::new(60, 0));
println!("Ready to work again"); println!("Ready to work again");
} }
let cred = th.open_invite().1 .0; let cred = th.open_invite().1 .0;
@ -1528,7 +1528,7 @@ fn stats_test_percent_blockage_migration_95() {
let h: NaiveTime = DateTime::time(&Utc::now()); let h: NaiveTime = DateTime::time(&Utc::now());
if h.hour() == 23 && h.minute() == 59 { if h.hour() == 23 && h.minute() == 59 {
println!("Wait for UTC 00:00"); println!("Wait for UTC 00:00");
thread::sleep(Duration::new(60,0)); thread::sleep(Duration::new(60, 0));
println!("Ready to work again"); println!("Ready to work again");
} }
let cred = th.open_invite().1 .0; let cred = th.open_invite().1 .0;
@ -1561,7 +1561,7 @@ fn stats_test_percent_blockage_migration_100() {
let h: NaiveTime = DateTime::time(&Utc::now()); let h: NaiveTime = DateTime::time(&Utc::now());
if h.hour() == 23 && h.minute() == 59 { if h.hour() == 23 && h.minute() == 59 {
println!("Wait for UTC 00:00"); println!("Wait for UTC 00:00");
thread::sleep(Duration::new(60,0)); thread::sleep(Duration::new(60, 0));
println!("Ready to work again"); println!("Ready to work again");
} }
let cred = th.open_invite().1 .0; let cred = th.open_invite().1 .0;
@ -1685,16 +1685,56 @@ fn print_stats_test_results(
resp_time: Vec<f64>, resp_time: Vec<f64>,
resp_handle_time: Vec<f64>, resp_handle_time: Vec<f64>,
) { ) {
let mean_req_size = if req_size.len() > 0 {mean(&req_size)} else {0.0}; let mean_req_size = if req_size.len() > 0 {
let req_std_dev = if req_size.len() > 1 {standard_deviation(&req_size, Some(mean_req_size))} else {0.0}; mean(&req_size)
let mean_req_time = if req_time.len() > 0 {mean(&req_time)} else {0.0}; } else {
let req_time_std_dev = if req_time.len() > 1 {standard_deviation(&req_time, Some(mean_req_time))} else {0.0}; 0.0
let mean_resp_size = if resp_size.len() > 0 {mean(&resp_size)} else {0.0}; };
let resp_std_dev = if resp_size.len() > 1 {standard_deviation(&resp_size, Some(mean_resp_size))} else {0.0}; let req_std_dev = if req_size.len() > 1 {
let mean_resp_time = if resp_time.len() > 0 {mean(&resp_time)} else {0.0}; standard_deviation(&req_size, Some(mean_req_size))
let resp_time_std_dev = if resp_time.len() > 1 {standard_deviation(&resp_time, Some(mean_resp_time))} else {0.0}; } else {
let mean_resp_handle_time = if resp_handle_time.len() > 0 {mean(&resp_handle_time)} else {0.0}; 0.0
let resp_handle_time_std_dev = if resp_handle_time.len() > 1 {standard_deviation(&resp_handle_time, Some(mean_resp_handle_time))} else {0.0}; };
let mean_req_time = if req_time.len() > 0 {
mean(&req_time)
} else {
0.0
};
let req_time_std_dev = if req_time.len() > 1 {
standard_deviation(&req_time, Some(mean_req_time))
} else {
0.0
};
let mean_resp_size = if resp_size.len() > 0 {
mean(&resp_size)
} else {
0.0
};
let resp_std_dev = if resp_size.len() > 1 {
standard_deviation(&resp_size, Some(mean_resp_size))
} else {
0.0
};
let mean_resp_time = if resp_time.len() > 0 {
mean(&resp_time)
} else {
0.0
};
let resp_time_std_dev = if resp_time.len() > 1 {
standard_deviation(&resp_time, Some(mean_resp_time))
} else {
0.0
};
let mean_resp_handle_time = if resp_handle_time.len() > 0 {
mean(&resp_handle_time)
} else {
0.0
};
let resp_handle_time_std_dev = if resp_handle_time.len() > 1 {
standard_deviation(&resp_handle_time, Some(mean_resp_handle_time))
} else {
0.0
};
println!("Average request size = {} bytes", mean_req_size); println!("Average request size = {} bytes", mean_req_size);
println!("Request size standard deviation = {} bytes", req_std_dev); println!("Request size standard deviation = {} bytes", req_std_dev);