implement random workload generator

This commit is contained in:
2025-09-06 18:24:55 +09:00
parent 4c55fd320d
commit ff4feb5faa
2 changed files with 23 additions and 1 deletions

View File

@@ -0,0 +1,21 @@
use rand::RngCore;
pub struct RandomUdpWorkloadGenerator<Rng: RngCore> {
rng: Rng,
}
impl<Rng: RngCore> RandomUdpWorkloadGenerator<Rng> {
pub fn new(rng: Rng) -> Self {
Self { rng }
}
pub fn generate_sized<const SIZE: usize>(&mut self) -> [u8; SIZE] {
let mut buf = [0u8; SIZE];
self.rng.fill_bytes(&mut buf);
buf
}
pub fn generate_boxed(&mut self, size: usize) -> Box<[u8]> {
let mut buf = vec![0u8; size].into_boxed_slice();
self.rng.fill_bytes(&mut buf);
buf
}
}

View File

@@ -1 +1,2 @@
pub mod random_flood; pub mod random_flood;
pub mod generator;