Cleanup encode benchmark, and change symbol size

1280 better matches the size used in other RaptorQ benchmarks that have been
published
This commit is contained in:
Christopher Berner 2019-04-13 00:06:23 -07:00
parent b32fa67e05
commit e9ede8802c

@ -2,14 +2,21 @@ use rand::Rng;
use raptorq::SourceBlockEncoder;
use std::time::Instant;
const TARGET_TOTAL_BYTES: usize = 100 * 1024 * 1024;
const SYMBOL_COUNTS: [usize; 11] = [10, 100, 250, 500, 1000, 2000, 4000, 10000, 20000, 40000, 56403];
const TARGET_TOTAL_BYTES: usize = 128 * 1024 * 1024;
const SYMBOL_COUNTS: [usize; 10] = [10, 100, 250, 500, 1000, 2000, 5000, 10000, 20000, 50000];
fn black_box(value: u64) {
if value == rand::thread_rng().gen() {
println!("{}", value);
}
}
fn main() {
let mut junk = 0;
let mut black_box_value = 0;
let symbol_size = 1280;
println!("Symbol size: {} bytes", symbol_size);
for symbol_count in SYMBOL_COUNTS.iter() {
let elements = symbol_count * 512;
let symbol_size = 512;
let elements = symbol_count * symbol_size as usize;
let mut data: Vec<u8> = vec![0; elements];
for i in 0..elements {
data[i] = rand::thread_rng().gen();
@ -20,7 +27,7 @@ fn main() {
for _ in 0..iterations {
let encoder = SourceBlockEncoder::new(1, symbol_size, &data);
let packets = encoder.repair_packets(0, 1);
junk += packets[0].data()[0] as u32;
black_box_value += packets[0].data()[0] as u64;
}
let elapsed = now.elapsed();
let elapsed = elapsed.as_secs() as f64 + elapsed.subsec_millis() as f64 * 0.001;
@ -31,5 +38,5 @@ fn main() {
elapsed,
throughput);
}
println!("{}", junk);
black_box(black_box_value);
}