ws load test: store global info hashes as Arc<[InfoHash]>

This commit is contained in:
Joakim Frostegård 2024-01-08 20:07:15 +01:00
parent 34167371b0
commit 27ecccd984
2 changed files with 4 additions and 4 deletions

View file

@ -18,7 +18,7 @@ pub struct Statistics {
#[derive(Clone)]
pub struct LoadTestState {
pub info_hashes: Arc<Vec<InfoHash>>,
pub info_hashes: Arc<[InfoHash]>,
pub statistics: Arc<Statistics>,
pub gamma: Arc<Gamma<f64>>,
}

View file

@ -36,10 +36,10 @@ fn run(config: Config) -> ::anyhow::Result<()> {
println!("Starting client with config: {:#?}", config);
let mut info_hashes = Vec::with_capacity(config.torrents.number_of_torrents);
let mut rng = SmallRng::from_entropy();
let mut info_hashes = Vec::with_capacity(config.torrents.number_of_torrents);
for _ in 0..config.torrents.number_of_torrents {
info_hashes.push(InfoHash(rng.gen()));
}
@ -51,7 +51,7 @@ fn run(config: Config) -> ::anyhow::Result<()> {
.unwrap();
let state = LoadTestState {
info_hashes: Arc::new(info_hashes),
info_hashes: Arc::from(info_hashes.into_boxed_slice()),
statistics: Arc::new(Statistics::default()),
gamma: Arc::new(gamma),
};