Added all tests but details of blockage migration

This commit is contained in:
onyinyang 2021-06-23 01:23:19 -04:00
parent 95615cf3ee
commit c9afa18795
No known key found for this signature in database
GPG Key ID: 156A6435430C2036
1 changed files with 178 additions and 30 deletions

View File

@ -819,44 +819,62 @@ fn stats_test_trust_level0_migration() {
);
}
#[test]
fn stats_test_trust_level_up() {
let mut th = TestHarness::new_buckets(10, 10);
println!("\n-------------Trust Level0 Migration----------------\n");
println!("\n---Trust Promotion + Migration to Level 1: 30 days----\n");
let mut req_size: Vec<f64> = Vec::new();
let mut resp_size: Vec<f64> = Vec::new();
let mut req_t_size: Vec<f64> = Vec::new();
let mut resp_t_size: Vec<f64> = Vec::new();
let mut resp_handle_t_size: Vec<f64> = Vec::new();
let mut tot_req_size: Vec<f64> = Vec::new();
let mut tot_resp_size: Vec<f64> = Vec::new();
let mut tot_req_t_size: Vec<f64> = Vec::new();
let mut tot_resp_t_size: Vec<f64> = Vec::new();
let mut tot_resp_handle_t_size: Vec<f64> = Vec::new();
let mut sec_req_size: Vec<f64> = Vec::new();
let mut sec_resp_size: Vec<f64> = Vec::new();
let mut sec_req_t_size: Vec<f64> = Vec::new();
let mut sec_resp_t_size: Vec<f64> = Vec::new();
let mut sec_resp_handle_t_size: Vec<f64> = Vec::new();
let mut three_req_size: Vec<f64> = Vec::new();
let mut three_resp_size: Vec<f64> = Vec::new();
let mut three_req_t_size: Vec<f64> = Vec::new();
let mut three_resp_t_size: Vec<f64> = Vec::new();
let mut three_resp_handle_t_size: Vec<f64> = Vec::new();
let mut four_req_size: Vec<f64> = Vec::new();
let mut four_resp_size: Vec<f64> = Vec::new();
let mut four_req_t_size: Vec<f64> = Vec::new();
let mut four_resp_t_size: Vec<f64> = Vec::new();
let mut four_resp_handle_t_size: Vec<f64> = Vec::new();
for _ in 0..1000 {
let cred = th.open_invite().1 .0;
th.advance_days(47);
th.advance_days(30);
let (tp_perf_stat, migcred) = th.trust_promotion(&cred);
let (perf_stat, cred1) = th.level0_migration(&cred, &migcred);
th.advance_days(20);
let (two_perf_stat, cred2) = th.level_up(&cred1);
th.advance_days(30);
th.advance_days(14);
let (sec_perf_stat, cred2) = th.level_up(&cred1);
th.advance_days(28);
let (three_perf_stat, cred3) = th.level_up(&cred2);
th.advance_days(60);
let (four_perf_stat, cred3) = th.level_up(&cred2);
req_size.push(perf_stat.req_len as f64);
req_t_size.push(perf_stat.req_t.as_secs_f64());
resp_size.push(perf_stat.resp_len as f64);
resp_t_size.push(perf_stat.resp_t.as_secs_f64());
resp_handle_t_size.push(perf_stat.resp_handle_t.as_secs_f64());
tot_req_size.push((perf_stat.req_len + tp_perf_stat.req_len) as f64);
tot_req_t_size.push((perf_stat.req_t + tp_perf_stat.req_t).as_secs_f64());
tot_resp_size.push((perf_stat.resp_len + tp_perf_stat.resp_len) as f64);
tot_resp_t_size.push((perf_stat.resp_t + tp_perf_stat.resp_t).as_secs_f64());
tot_resp_handle_t_size
.push((perf_stat.resp_handle_t + tp_perf_stat.resp_handle_t).as_secs_f64());
th.advance_days(56);
let (four_perf_stat, _) = th.level_up(&cred3);
req_size.push((perf_stat.req_len + tp_perf_stat.req_len) as f64);
req_t_size.push((perf_stat.req_t + tp_perf_stat.req_t).as_secs_f64());
resp_size.push((perf_stat.resp_len + tp_perf_stat.resp_len) as f64);
resp_t_size.push((perf_stat.resp_t + tp_perf_stat.resp_t).as_secs_f64());
resp_handle_t_size.push((perf_stat.resp_handle_t + tp_perf_stat.resp_handle_t).as_secs_f64());
sec_req_size.push(sec_perf_stat.req_len as f64);
sec_req_t_size.push(sec_perf_stat.req_t.as_secs_f64());
sec_resp_size.push(sec_perf_stat.resp_len as f64);
sec_resp_t_size.push(sec_perf_stat.resp_t.as_secs_f64());
sec_resp_handle_t_size.push(sec_perf_stat.resp_handle_t.as_secs_f64());
three_req_size.push(three_perf_stat.req_len as f64);
three_req_t_size.push(three_perf_stat.req_t.as_secs_f64());
three_resp_size.push(three_perf_stat.resp_len as f64);
three_resp_t_size.push(three_perf_stat.resp_t.as_secs_f64());
three_resp_handle_t_size.push(three_perf_stat.resp_handle_t.as_secs_f64());
four_req_size.push(four_perf_stat.req_len as f64);
four_req_t_size.push(four_perf_stat.req_t.as_secs_f64());
four_resp_size.push(four_perf_stat.resp_len as f64);
four_resp_t_size.push(four_perf_stat.resp_t.as_secs_f64());
four_resp_handle_t_size.push(four_perf_stat.resp_handle_t.as_secs_f64());
}
print_stats_test_results(
@ -867,14 +885,144 @@ fn stats_test_trust_level_up() {
resp_handle_t_size,
);
println!("\n-------Total Trust Promotion to Level 1-------\n");
println!("\n-------Trust Promotion to Level 2: 44 days-------\n");
print_stats_test_results(
tot_req_size,
tot_req_t_size,
tot_resp_size,
tot_resp_t_size,
tot_resp_handle_t_size,
sec_req_size,
sec_req_t_size,
sec_resp_size,
sec_resp_t_size,
sec_resp_handle_t_size,
);
println!("\n-------Trust Promotion to Level 3: 72 days------\n");
print_stats_test_results(
three_req_size,
three_req_t_size,
three_resp_size,
three_resp_t_size,
three_resp_handle_t_size,
);
println!("\n-------Trust Promotion to Level 4: 128 days------\n");
print_stats_test_results(
four_req_size,
four_req_t_size,
four_resp_size,
four_resp_t_size,
four_resp_handle_t_size,
);
}
#[test]
fn stats_test_invitations() {
let mut th = TestHarness::new_buckets(10, 10);
println!("\n---------------Issue Invitation----------------\n");
let mut req_size: Vec<f64> = Vec::new();
let mut resp_size: Vec<f64> = Vec::new();
let mut req_t_size: Vec<f64> = Vec::new();
let mut resp_t_size: Vec<f64> = Vec::new();
let mut resp_handle_t_size: Vec<f64> = Vec::new();
let mut red_req_size: Vec<f64> = Vec::new();
let mut red_resp_size: Vec<f64> = Vec::new();
let mut red_req_t_size: Vec<f64> = Vec::new();
let mut red_resp_t_size: Vec<f64> = Vec::new();
let mut red_resp_handle_t_size: Vec<f64> = Vec::new();
for _ in 0..1000 {
let cred = th.open_invite().1 .0;
th.advance_days(30);
let (_, migcred) = th.trust_promotion(&cred);
let (_, cred1) = th.level0_migration(&cred, &migcred);
th.advance_days(14);
let (_, cred2) = th.level_up(&cred1);
th.advance_days(28);
let (perf_stat, (cred2a, invite)) = th.issue_invite(&cred2);
let (bob_perf_stat, bob_cred) = th.redeem_invite(&invite);
req_size.push(perf_stat.req_len as f64);
req_t_size.push(perf_stat.req_t.as_secs_f64());
resp_size.push(perf_stat.resp_len as f64);
resp_t_size.push(perf_stat.resp_t.as_secs_f64());
resp_handle_t_size.push(perf_stat.resp_handle_t.as_secs_f64());
red_req_size.push(bob_perf_stat.req_len as f64);
red_req_t_size.push(bob_perf_stat.req_t.as_secs_f64());
red_resp_size.push(bob_perf_stat.resp_len as f64);
red_resp_t_size.push(bob_perf_stat.resp_t.as_secs_f64());
red_resp_handle_t_size.push(bob_perf_stat.resp_handle_t.as_secs_f64());
}
print_stats_test_results(
req_size,
req_t_size,
resp_size,
resp_t_size,
resp_handle_t_size,
);
println!("\n---------------Redeem Invitation----------------\n");
print_stats_test_results(
red_req_size,
red_req_t_size,
red_resp_size,
red_resp_t_size,
red_resp_handle_t_size,
);
}
#[test]
fn stats_test_blockage migration() {
let mut th = TestHarness::new_buckets(10, 10);
println!("\n---------------Blockage Migration----------------\n");
let mut req_size: Vec<f64> = Vec::new();
let mut resp_size: Vec<f64> = Vec::new();
let mut req_t_size: Vec<f64> = Vec::new();
let mut resp_t_size: Vec<f64> = Vec::new();
let mut resp_handle_t_size: Vec<f64> = Vec::new();
let mut red_req_size: Vec<f64> = Vec::new();
let mut red_resp_size: Vec<f64> = Vec::new();
let mut red_req_t_size: Vec<f64> = Vec::new();
let mut red_resp_t_size: Vec<f64> = Vec::new();
let mut red_resp_handle_t_size: Vec<f64> = Vec::new();
for _ in 0..1000 {
let cred = th.open_invite().1 .0;
th.advance_days(30);
let (_, migcred) = th.trust_promotion(&cred);
let (_, cred1) = th.level0_migration(&cred, &migcred);
th.advance_days(14);
let (_, cred2) = th.level_up(&cred1);
th.advance_days(28);
let (perf_stat, (cred2a, invite)) = th.issue_invite(&cred2);
let (bob_perf_stat, bob_cred) = th.redeem_invite(&invite);
req_size.push(perf_stat.req_len as f64);
req_t_size.push(perf_stat.req_t.as_secs_f64());
resp_size.push(perf_stat.resp_len as f64);
resp_t_size.push(perf_stat.resp_t.as_secs_f64());
resp_handle_t_size.push(perf_stat.resp_handle_t.as_secs_f64());
red_req_size.push(bob_perf_stat.req_len as f64);
red_req_t_size.push(bob_perf_stat.req_t.as_secs_f64());
red_resp_size.push(bob_perf_stat.resp_len as f64);
red_resp_t_size.push(bob_perf_stat.resp_t.as_secs_f64());
red_resp_handle_t_size.push(bob_perf_stat.resp_handle_t.as_secs_f64());
}
print_stats_test_results(
req_size,
req_t_size,
resp_size,
resp_t_size,
resp_handle_t_size,
);
println!("\n---------------Redeem Invitation----------------\n");
print_stats_test_results(
red_req_size,
red_req_t_size,
red_resp_size,
red_resp_t_size,
red_resp_handle_t_size,
);
}
#[test]
fn stats_test_blocked_bridges() {