udp bench: use gamma distribution for torrent selection

This commit is contained in:
Joakim Frostegård 2022-10-26 20:03:59 +02:00
parent db561a1101
commit 84f420e2c5
3 changed files with 12 additions and 10 deletions

View file

@ -5,7 +5,7 @@ use aquatic_common::CanonicalSocketAddr;
use crossbeam_channel::{Receiver, Sender};
use indicatif::ProgressIterator;
use rand::Rng;
use rand_distr::Pareto;
use rand_distr::Gamma;
use aquatic_udp::common::*;
use aquatic_udp_protocol::*;
@ -81,14 +81,14 @@ pub fn create_requests(
info_hashes: &[InfoHash],
number: usize,
) -> Vec<(AnnounceRequest, CanonicalSocketAddr)> {
let pareto = Pareto::new(1., PARETO_SHAPE).unwrap();
let gamma = Gamma::new(GAMMA_SHAPE, GAMMA_SCALE).unwrap();
let max_index = info_hashes.len() - 1;
let mut requests = Vec::new();
for _ in 0..number {
let info_hash_index = pareto_usize(rng, pareto, max_index);
let info_hash_index = gamma_usize(rng, gamma, max_index);
let request = AnnounceRequest {
connection_id: ConnectionId(0),