Skip to content

Commit

Permalink
Fix compilation error in benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
cberner committed Sep 21, 2024
1 parent 329682c commit 880a9c0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ jobs:
- name: Run tests
run: make test

- name: Compile benchmarks
run: cargo bench --feature benchmarking --no-run

- name: Run tests (no-std)
run: cargo test --no-default-features

Expand Down
10 changes: 5 additions & 5 deletions benches/codec_benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fn criterion_benchmark(c: &mut Criterion) {
Benchmark::new("", move |b| {
b.iter(|| {
let config = ObjectTransmissionInformation::new(0, symbol_size, 0, 1, 1);
let encoder = SourceBlockEncoder::new2(1, &config, &encode_data);
let encoder = SourceBlockEncoder::new(1, &config, &encode_data);
return encoder.source_packets();
})
})
Expand All @@ -91,8 +91,8 @@ fn criterion_benchmark(c: &mut Criterion) {
Benchmark::new("", move |b| {
b.iter(|| {
let config = ObjectTransmissionInformation::new(0, symbol_size, 0, 1, 1);
let encoder = SourceBlockEncoder::new2(1, &config, &roundtrip_data);
let mut decoder = SourceBlockDecoder::new2(1, &config, elements as u64);
let encoder = SourceBlockEncoder::new(1, &config, &roundtrip_data);
let mut decoder = SourceBlockDecoder::new(1, &config, elements as u64);
return decoder.decode(encoder.source_packets());
})
})
Expand All @@ -105,9 +105,9 @@ fn criterion_benchmark(c: &mut Criterion) {
Benchmark::new("", move |b| {
b.iter(|| {
let config = ObjectTransmissionInformation::new(0, symbol_size, 0, 1, 1);
let encoder = SourceBlockEncoder::new2(1, &config, &repair_data);
let encoder = SourceBlockEncoder::new(1, &config, &repair_data);
let repair_packets = (elements / symbol_size as usize) as u32;
let mut decoder = SourceBlockDecoder::new2(1, &config, elements as u64);
let mut decoder = SourceBlockDecoder::new(1, &config, elements as u64);
return decoder.decode(encoder.repair_packets(0, repair_packets));
})
})
Expand Down
4 changes: 2 additions & 2 deletions benches/decode_benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ fn benchmark(symbol_size: u16, overhead: f64) -> u64 {

let iterations = TARGET_TOTAL_BYTES / elements;
let config = ObjectTransmissionInformation::new(0, symbol_size, 0, 1, 1);
let encoder = SourceBlockEncoder::new2(1, &config, &data);
let encoder = SourceBlockEncoder::new(1, &config, &data);
let elements_and_overhead = (symbol_count as f64 * (1.0 + overhead)) as u32;
let mut packets = encoder.repair_packets(0, iterations as u32 * elements_and_overhead);
let now = Instant::now();
for _ in 0..iterations {
let mut decoder = SourceBlockDecoder::new2(1, &config, elements as u64);
let mut decoder = SourceBlockDecoder::new(1, &config, elements as u64);
let start = packets.len() - elements_and_overhead as usize;
if let Some(result) = decoder.decode(packets.drain(start..)) {
black_box_value += result[0] as u64;
Expand Down
4 changes: 2 additions & 2 deletions benches/encode_benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ fn benchmark(symbol_size: u16, pre_plan: bool) -> u64 {
let config = ObjectTransmissionInformation::new(0, symbol_size, 0, 1, 1);
for _ in 0..iterations {
let encoder = if let Some(ref plan) = plan {
SourceBlockEncoder::with_encoding_plan2(1, &config, &data, plan)
SourceBlockEncoder::with_encoding_plan(1, &config, &data, plan)
} else {
SourceBlockEncoder::new2(1, &config, &data)
SourceBlockEncoder::new(1, &config, &data)
};
let packets = encoder.repair_packets(0, 1);
black_box_value += packets[0].data()[0] as u64;
Expand Down

0 comments on commit 880a9c0

Please sign in to comment.