mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 18:55:32 +00:00
bench_announce_scrape: clean up a bit, fix logic error
This commit is contained in:
parent
eed0acd15f
commit
9943e49d0e
1 changed files with 93 additions and 85 deletions
|
|
@ -9,22 +9,24 @@ use aquatic::handler::*;
|
|||
|
||||
|
||||
const PARETO_SHAPE: f64 = 3.0;
|
||||
const ANNOUNCE_ITERATIONS: usize = 5_000_000;
|
||||
const ANNOUNCE_ITERATIONS: usize = 500_000;
|
||||
const SCRAPE_ITERATIONS: usize = 500_000;
|
||||
const SCRAPE_NUM_HASHES: usize = 10;
|
||||
const NUM_INFO_HASHES: usize = 500_000;
|
||||
|
||||
|
||||
fn main(){
|
||||
let mut rng = SmallRng::from_rng(thread_rng()).unwrap();
|
||||
let info_hashes = create_info_hashes(&mut rng);
|
||||
let state = State::new();
|
||||
|
||||
{
|
||||
println!("benchmark: handle_announce_requests\n");
|
||||
|
||||
println!("generating data..");
|
||||
|
||||
let state = State::new();
|
||||
let mut responses = Vec::new();
|
||||
|
||||
let mut rng = SmallRng::from_rng(thread_rng()).unwrap();
|
||||
|
||||
let info_hashes = create_info_hashes(&mut rng);
|
||||
let mut announce_requests = create_announce_requests(&mut rng, &info_hashes);
|
||||
|
||||
let time = Time(Instant::now());
|
||||
|
|
@ -69,14 +71,19 @@ fn main(){
|
|||
}
|
||||
}
|
||||
|
||||
println!("avg num peers: {:.2}", total_num_peers / ANNOUNCE_ITERATIONS as f64);
|
||||
println!("max num peers: {:.2}", max_num_peers);
|
||||
println!("avg num peers returned: {:.2}", total_num_peers / ANNOUNCE_ITERATIONS as f64);
|
||||
println!("max num peers returned: {:.2}", max_num_peers);
|
||||
}
|
||||
|
||||
state.connections.clear();
|
||||
|
||||
{
|
||||
println!("\n\nbenchmark: handle_scrape_requests\n");
|
||||
|
||||
println!("generating data..");
|
||||
|
||||
let mut responses = Vec::new();
|
||||
|
||||
let mut scrape_requests = create_scrape_requests(&mut rng, &info_hashes);
|
||||
|
||||
let time = Time(Instant::now());
|
||||
|
|
@ -120,7 +127,8 @@ fn main(){
|
|||
}
|
||||
}
|
||||
|
||||
println!("avg num peers: {:.2}", total_num_peers / SCRAPE_ITERATIONS as f64);
|
||||
println!("avg num peers reported: {:.2}", total_num_peers / (SCRAPE_ITERATIONS as f64 * SCRAPE_NUM_HASHES as f64));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -175,7 +183,7 @@ fn create_scrape_requests(
|
|||
for _ in 0..SCRAPE_ITERATIONS {
|
||||
let mut request_info_hashes = Vec::new();
|
||||
|
||||
for _ in 0..10 {
|
||||
for _ in 0..SCRAPE_NUM_HASHES {
|
||||
let info_hash_index = pareto_usize(rng, pareto, max_index);
|
||||
request_info_hashes.push(info_hashes[info_hash_index])
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue