Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ serde = {version = "1.0.102", features=["std", "derive"], optional = true}
pyo3 = {version = "0.24.1", features=["extension-module", "abi3-py37"], optional = true }

[dev-dependencies]
criterion = "0.3"
criterion = "0.4"
primal = "0.3"
rand = "0.8"
threadpool = "1.7"
Expand Down
122 changes: 58 additions & 64 deletions benches/codec_benchmark.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use criterion::criterion_group;
use criterion::criterion_main;
use criterion::Benchmark;
use criterion::BenchmarkId;
use criterion::Criterion;
use criterion::Throughput;

Expand All @@ -24,46 +24,43 @@ fn criterion_benchmark(c: &mut Criterion) {

let symbol1_mul_scalar = symbol1.clone();
let octet1_mul_scalar = octet1.clone();
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
})
let mut group = c.benchmark_group("Symbol mulassign_scalar()");
group.throughput(Throughput::Bytes(symbol1.len() as u64));
group.bench_function(BenchmarkId::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 u64)),
);
});
group.finish();

let symbol1_addassign = symbol1.clone();
let symbol2_addassign = symbol2.clone();
c.bench(
"Symbol +=",
Benchmark::new("", move |b| {
b.iter(|| {
let mut temp = symbol1_addassign.clone();
temp += &symbol2_addassign;
temp
})
let mut group = c.benchmark_group("Symbol +=");
group.throughput(Throughput::Bytes(symbol1.len() as u64));
group.bench_function(BenchmarkId::new("", ""), move |b| {
b.iter(|| {
let mut temp = symbol1_addassign.clone();
temp += &symbol2_addassign;
temp
})
.throughput(Throughput::Bytes(symbol1.len() as u64)),
);
});
group.finish();

let symbol1_fma = symbol1.clone();
let symbol2_fma = symbol2.clone();
let octet1_fma = octet1.clone();
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
})
let mut group = c.benchmark_group("Symbol FMA");
group.throughput(Throughput::Bytes(symbol1.len() as u64));
group.bench_function(BenchmarkId::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 u64)),
);
});
group.finish();

let elements = 10 * 1024;
let symbol_size = 512;
Expand All @@ -73,46 +70,43 @@ fn criterion_benchmark(c: &mut Criterion) {
}

let encode_data = data.clone();
c.bench(
"encode 10KB",
Benchmark::new("", move |b| {
b.iter(|| {
let config = ObjectTransmissionInformation::new(0, symbol_size, 0, 1, 1);
let encoder = SourceBlockEncoder::new(1, &config, &encode_data);
return encoder.source_packets();
})
let mut group = c.benchmark_group("encode 10KB");
group.throughput(Throughput::Bytes(data.len() as u64));
group.bench_function(BenchmarkId::new("", ""), move |b| {
b.iter(|| {
let config = ObjectTransmissionInformation::new(0, symbol_size, 0, 1, 1);
let encoder = SourceBlockEncoder::new(1, &config, &encode_data);
return encoder.source_packets();
})
.throughput(Throughput::Bytes(data.len() as u64)),
);
});
group.finish();

let roundtrip_data = data.clone();
c.bench(
"roundtrip 10KB",
Benchmark::new("", move |b| {
b.iter(|| {
let config = ObjectTransmissionInformation::new(0, symbol_size, 0, 1, 1);
let encoder = SourceBlockEncoder::new(1, &config, &roundtrip_data);
let mut decoder = SourceBlockDecoder::new(1, &config, elements as u64);
return decoder.decode(encoder.source_packets());
})
let mut group = c.benchmark_group("roundtrip 10KB");
group.throughput(Throughput::Bytes(data.len() as u64));
group.bench_function(BenchmarkId::new("", ""), move |b| {
b.iter(|| {
let config = ObjectTransmissionInformation::new(0, symbol_size, 0, 1, 1);
let encoder = SourceBlockEncoder::new(1, &config, &roundtrip_data);
let mut decoder = SourceBlockDecoder::new(1, &config, elements as u64);
return decoder.decode(encoder.source_packets());
})
.throughput(Throughput::Bytes(data.len() as u64)),
);
});
group.finish();

let repair_data = data.clone();
c.bench(
"roundtrip repair 10KB",
Benchmark::new("", move |b| {
b.iter(|| {
let config = ObjectTransmissionInformation::new(0, symbol_size, 0, 1, 1);
let encoder = SourceBlockEncoder::new(1, &config, &repair_data);
let repair_packets = (elements / symbol_size as usize) as u32;
let mut decoder = SourceBlockDecoder::new(1, &config, elements as u64);
return decoder.decode(encoder.repair_packets(0, repair_packets));
})
let mut group = c.benchmark_group("roundtrip repair 10KB");
group.throughput(Throughput::Bytes(data.len() as u64));
group.bench_function(BenchmarkId::new("", ""), move |b| {
b.iter(|| {
let config = ObjectTransmissionInformation::new(0, symbol_size, 0, 1, 1);
let encoder = SourceBlockEncoder::new(1, &config, &repair_data);
let repair_packets = (elements / symbol_size as usize) as u32;
let mut decoder = SourceBlockDecoder::new(1, &config, elements as u64);
return decoder.decode(encoder.repair_packets(0, repair_packets));
})
.throughput(Throughput::Bytes(data.len() as u64)),
);
});
group.finish();
}

criterion_group!(benches, criterion_benchmark);
Expand Down
Loading