Skip to content

Commit

Permalink
ospf: fix benchmarking code compilation
Browse files Browse the repository at this point in the history
The benchmarking code broke due to the new cryptographic authentication
additions. This commit fixes the problem.

In the future, the CI should be updated to catch such issues and
ensure the benchmark code always compiles (and detect performance
regressions as well!).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
  • Loading branch information
rwestphal committed Jan 25, 2024
1 parent dab02ff commit 7b8710c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion holo-ospf/benches/packet_decoding.rs
Expand Up @@ -3,6 +3,7 @@
use std::hint::black_box;
use std::sync::LazyLock as Lazy;

use bytes::Bytes;
use criterion::{criterion_group, criterion_main, Criterion};
use holo_ospf::packet::*;
use holo_ospf::version::Ospfv2;
Expand All @@ -25,7 +26,9 @@ static BYTES: Lazy<Vec<u8>> = Lazy::new(|| {

fn packet_decode(n: u64) {
for _ in 0..n {
let _ = Packet::<Ospfv2>::decode(AddressFamily::Ipv4, &BYTES).unwrap();
let mut buf = Bytes::copy_from_slice(&BYTES);
let _ = Packet::<Ospfv2>::decode(AddressFamily::Ipv4, &mut buf, None)
.unwrap();
}
}

Expand Down
3 changes: 2 additions & 1 deletion holo-ospf/benches/packet_encoding.rs
Expand Up @@ -18,6 +18,7 @@ static PACKET: Lazy<Packet<Ospfv2>> = Lazy::new(|| {
pkt_type: PacketType::LsUpdate,
router_id: Ipv4Addr::from_str("2.2.2.2").unwrap(),
area_id: Ipv4Addr::from_str("0.0.0.1").unwrap(),
auth_seqno: None,
},
lsas: vec![
Lsa::new(
Expand Down Expand Up @@ -64,7 +65,7 @@ static PACKET: Lazy<Packet<Ospfv2>> = Lazy::new(|| {

fn packet_encode(n: u64) {
for _ in 0..n {
PACKET.encode();
PACKET.encode(None);
}
}

Expand Down

0 comments on commit 7b8710c

Please sign in to comment.