mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 02:35:31 +00:00
udp load test: store info hashes as Arc slice to save space
This commit is contained in:
parent
0eaa4475e2
commit
99791c7154
3 changed files with 7 additions and 7 deletions
|
|
@ -27,7 +27,7 @@ pub struct Statistics {
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct LoadTestState {
|
pub struct LoadTestState {
|
||||||
pub info_hashes: Arc<Vec<InfoHash>>,
|
pub info_hashes: Arc<[InfoHash]>,
|
||||||
pub statistics: Arc<Statistics>,
|
pub statistics: Arc<Statistics>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ pub fn run(config: Config) -> ::anyhow::Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let state = LoadTestState {
|
let state = LoadTestState {
|
||||||
info_hashes: Arc::new(info_hashes),
|
info_hashes: Arc::from(info_hashes.into_boxed_slice()),
|
||||||
statistics: Arc::new(Statistics::default()),
|
statistics: Arc::new(Statistics::default()),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ use crate::utils::*;
|
||||||
pub fn process_response(
|
pub fn process_response(
|
||||||
rng: &mut impl Rng,
|
rng: &mut impl Rng,
|
||||||
gamma: Gamma<f64>,
|
gamma: Gamma<f64>,
|
||||||
info_hashes: &Arc<Vec<InfoHash>>,
|
info_hashes: &Arc<[InfoHash]>,
|
||||||
config: &Config,
|
config: &Config,
|
||||||
torrent_peers: &mut TorrentPeerMap,
|
torrent_peers: &mut TorrentPeerMap,
|
||||||
response: Response,
|
response: Response,
|
||||||
|
|
@ -89,7 +89,7 @@ pub fn process_response(
|
||||||
fn if_torrent_peer_move_and_create_random_request(
|
fn if_torrent_peer_move_and_create_random_request(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
rng: &mut impl Rng,
|
rng: &mut impl Rng,
|
||||||
info_hashes: &Arc<Vec<InfoHash>>,
|
info_hashes: &Arc<[InfoHash]>,
|
||||||
torrent_peers: &mut TorrentPeerMap,
|
torrent_peers: &mut TorrentPeerMap,
|
||||||
transaction_id: TransactionId,
|
transaction_id: TransactionId,
|
||||||
) -> Option<Request> {
|
) -> Option<Request> {
|
||||||
|
|
@ -110,7 +110,7 @@ fn if_torrent_peer_move_and_create_random_request(
|
||||||
fn create_random_request(
|
fn create_random_request(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
rng: &mut impl Rng,
|
rng: &mut impl Rng,
|
||||||
info_hashes: &Arc<Vec<InfoHash>>,
|
info_hashes: &Arc<[InfoHash]>,
|
||||||
transaction_id: TransactionId,
|
transaction_id: TransactionId,
|
||||||
torrent_peer: &TorrentPeer,
|
torrent_peer: &TorrentPeer,
|
||||||
) -> Request {
|
) -> Request {
|
||||||
|
|
@ -168,7 +168,7 @@ fn create_announce_request(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_scrape_request(
|
fn create_scrape_request(
|
||||||
info_hashes: &Arc<Vec<InfoHash>>,
|
info_hashes: &Arc<[InfoHash]>,
|
||||||
torrent_peer: &TorrentPeer,
|
torrent_peer: &TorrentPeer,
|
||||||
transaction_id: TransactionId,
|
transaction_id: TransactionId,
|
||||||
) -> Request {
|
) -> Request {
|
||||||
|
|
@ -192,7 +192,7 @@ fn create_torrent_peer(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
rng: &mut impl Rng,
|
rng: &mut impl Rng,
|
||||||
gamma: Gamma<f64>,
|
gamma: Gamma<f64>,
|
||||||
info_hashes: &Arc<Vec<InfoHash>>,
|
info_hashes: &Arc<[InfoHash]>,
|
||||||
connection_id: ConnectionId,
|
connection_id: ConnectionId,
|
||||||
) -> TorrentPeer {
|
) -> TorrentPeer {
|
||||||
let num_scape_hashes = rng.gen_range(1..config.requests.scrape_max_torrents);
|
let num_scape_hashes = rng.gen_range(1..config.requests.scrape_max_torrents);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue