mirror of
https://github.com/cberner/raptorq.git
synced 2024-06-30 18:51:43 +00:00
Add throughput measurement to benchmark
This commit is contained in:
parent
fc0ae5d162
commit
05a9ef2355
@ -9,6 +9,8 @@ use raptorq::SourceBlockEncoder;
|
||||
use raptorq::SourceBlockDecoder;
|
||||
use raptorq::Octet;
|
||||
use raptorq::Symbol;
|
||||
use criterion::Benchmark;
|
||||
use criterion::Throughput;
|
||||
|
||||
|
||||
fn criterion_benchmark(c: &mut Criterion) {
|
||||
@ -27,28 +29,28 @@ fn criterion_benchmark(c: &mut Criterion) {
|
||||
|
||||
let symbol1_mul_scalar = symbol1.clone();
|
||||
let octet1_mul_scalar = octet1.clone();
|
||||
c.bench_function("Symbol mulassign_scalar()", move |b| b.iter(|| {
|
||||
c.bench("Symbol mulassign_scalar()", Benchmark::new("", move |b| b.iter(|| {
|
||||
let mut temp = symbol1_mul_scalar.clone();
|
||||
temp.mulassign_scalar(&octet1_mul_scalar);
|
||||
temp
|
||||
}));
|
||||
})).throughput(Throughput::Bytes(symbol1.len() as u32)));
|
||||
|
||||
let symbol1_addassign = symbol1.clone();
|
||||
let symbol2_addassign = symbol2.clone();
|
||||
c.bench_function("Symbol +=", move |b| b.iter(|| {
|
||||
c.bench("Symbol +=", Benchmark::new("", move |b| b.iter(|| {
|
||||
let mut temp = symbol1_addassign.clone();
|
||||
temp += &symbol2_addassign;
|
||||
temp
|
||||
}));
|
||||
})).throughput(Throughput::Bytes(symbol1.len() as u32)));
|
||||
|
||||
let symbol1_fma = symbol1.clone();
|
||||
let symbol2_fma = symbol2.clone();
|
||||
let octet1_fma = octet1.clone();
|
||||
c.bench_function("Symbol FMA", move |b| b.iter(|| {
|
||||
c.bench("Symbol FMA", Benchmark::new("", move |b| b.iter(|| {
|
||||
let mut temp = symbol1_fma.clone();
|
||||
temp.fused_addassign_mul_scalar(&symbol2_fma, &octet1_fma);
|
||||
temp
|
||||
}));
|
||||
})).throughput(Throughput::Bytes(symbol1.len() as u32)));
|
||||
|
||||
|
||||
let elements = 10*1024;
|
||||
@ -59,13 +61,13 @@ fn criterion_benchmark(c: &mut Criterion) {
|
||||
}
|
||||
|
||||
let encode_data = data.clone();
|
||||
c.bench_function("encode 10KB", move |b| b.iter(|| {
|
||||
c.bench("encode 10KB", Benchmark::new("", move |b| b.iter(|| {
|
||||
let encoder = SourceBlockEncoder::new(1, symbol_size, &encode_data);
|
||||
return encoder.all_source_packets();
|
||||
}));
|
||||
})).throughput(Throughput::Bytes(data.len() as u32)));
|
||||
|
||||
let roundtrip_data = data.clone();
|
||||
c.bench_function("roundtrip 10KB", move |b| b.iter(|| {
|
||||
c.bench("roundtrip 10KB", Benchmark::new("", move |b| b.iter(|| {
|
||||
let encoder = SourceBlockEncoder::new(1, symbol_size, &roundtrip_data);
|
||||
let mut decoder = SourceBlockDecoder::new(1, symbol_size, elements as u64);
|
||||
let mut result = None;
|
||||
@ -73,10 +75,10 @@ fn criterion_benchmark(c: &mut Criterion) {
|
||||
result = decoder.parse(packet);
|
||||
}
|
||||
return result
|
||||
}));
|
||||
})).throughput(Throughput::Bytes(data.len() as u32)));
|
||||
|
||||
let repair_data = data.clone();
|
||||
c.bench_function("roundtrip repair 10KB", move |b| b.iter(|| {
|
||||
c.bench("roundtrip repair 10KB", Benchmark::new("", move |b| b.iter(|| {
|
||||
let encoder = SourceBlockEncoder::new(1, symbol_size, &repair_data);
|
||||
let mut decoder = SourceBlockDecoder::new(1, symbol_size, elements as u64);
|
||||
let mut result = None;
|
||||
@ -84,7 +86,7 @@ fn criterion_benchmark(c: &mut Criterion) {
|
||||
result = decoder.parse(packet);
|
||||
}
|
||||
return result
|
||||
}));
|
||||
})).throughput(Throughput::Bytes(data.len() as u32)));
|
||||
}
|
||||
|
||||
criterion_group!(benches, criterion_benchmark);
|
||||
|
Loading…
Reference in New Issue
Block a user