mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-01 10:15:31 +00:00
Use gamma distribution for all load testers
This commit is contained in:
parent
2b9db63984
commit
db561a1101
12 changed files with 65 additions and 55 deletions
|
|
@ -21,7 +21,7 @@ const MAX_PACKET_SIZE: usize = 8192;
|
|||
|
||||
pub fn run_worker_thread(
|
||||
state: LoadTestState,
|
||||
pareto: Gamma<f64>,
|
||||
gamma: Gamma<f64>,
|
||||
config: &Config,
|
||||
addr: SocketAddr,
|
||||
) {
|
||||
|
|
@ -80,7 +80,7 @@ pub fn run_worker_thread(
|
|||
|
||||
let opt_request = process_response(
|
||||
&mut rng,
|
||||
pareto,
|
||||
gamma,
|
||||
&state.info_hashes,
|
||||
&config,
|
||||
&mut torrent_peers,
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use crate::utils::*;
|
|||
|
||||
pub fn process_response(
|
||||
rng: &mut impl Rng,
|
||||
pareto: Gamma<f64>,
|
||||
gamma: Gamma<f64>,
|
||||
info_hashes: &Arc<Vec<InfoHash>>,
|
||||
config: &Config,
|
||||
torrent_peers: &mut TorrentPeerMap,
|
||||
|
|
@ -32,7 +32,7 @@ pub fn process_response(
|
|||
torrent_peer
|
||||
})
|
||||
.unwrap_or_else(|| {
|
||||
create_torrent_peer(config, rng, pareto, info_hashes, r.connection_id)
|
||||
create_torrent_peer(config, rng, gamma, info_hashes, r.connection_id)
|
||||
});
|
||||
|
||||
let new_transaction_id = generate_transaction_id(rng);
|
||||
|
|
@ -190,7 +190,7 @@ fn create_scrape_request(
|
|||
fn create_torrent_peer(
|
||||
config: &Config,
|
||||
rng: &mut impl Rng,
|
||||
pareto: Gamma<f64>,
|
||||
gamma: Gamma<f64>,
|
||||
info_hashes: &Arc<Vec<InfoHash>>,
|
||||
connection_id: ConnectionId,
|
||||
) -> TorrentPeer {
|
||||
|
|
@ -199,10 +199,10 @@ fn create_torrent_peer(
|
|||
let mut scrape_hash_indeces = Vec::new();
|
||||
|
||||
for _ in 0..num_scape_hashes {
|
||||
scrape_hash_indeces.push(select_info_hash_index(config, rng, pareto))
|
||||
scrape_hash_indeces.push(select_info_hash_index(config, rng, gamma))
|
||||
}
|
||||
|
||||
let info_hash_index = select_info_hash_index(config, rng, pareto);
|
||||
let info_hash_index = select_info_hash_index(config, rng, gamma);
|
||||
|
||||
TorrentPeer {
|
||||
info_hash: info_hashes[info_hash_index],
|
||||
|
|
@ -213,6 +213,6 @@ fn create_torrent_peer(
|
|||
}
|
||||
}
|
||||
|
||||
fn select_info_hash_index(config: &Config, rng: &mut impl Rng, pareto: Gamma<f64>) -> usize {
|
||||
pareto_usize(rng, pareto, config.requests.number_of_torrents - 1)
|
||||
fn select_info_hash_index(config: &Config, rng: &mut impl Rng, gamma: Gamma<f64>) -> usize {
|
||||
gamma_usize(rng, gamma, config.requests.number_of_torrents - 1)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue