From 880a9c0612b542e7e399292a3117b99a4ae48878 Mon Sep 17 00:00:00 2001 From: Christopher Berner Date: Sat, 21 Sep 2024 12:55:56 -0700 Subject: [PATCH] Fix compilation error in benchmarks --- .github/workflows/ci.yml | 3 +++ benches/codec_benchmark.rs | 10 +++++----- benches/decode_benchmark.rs | 4 ++-- benches/encode_benchmark.rs | 4 ++-- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f55e17d..af09993 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/benches/codec_benchmark.rs b/benches/codec_benchmark.rs index 5cfa829..44761ea 100644 --- a/benches/codec_benchmark.rs +++ b/benches/codec_benchmark.rs @@ -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(); }) }) @@ -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()); }) }) @@ -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)); }) }) diff --git a/benches/decode_benchmark.rs b/benches/decode_benchmark.rs index 5307d56..bc278b8 100644 --- a/benches/decode_benchmark.rs +++ b/benches/decode_benchmark.rs @@ -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; diff --git a/benches/encode_benchmark.rs b/benches/encode_benchmark.rs index 148aedc..e09b5bb 100644 --- a/benches/encode_benchmark.rs +++ b/benches/encode_benchmark.rs @@ -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;