use criterion::{criterion_group, criterion_main, Criterion}; use serde_klv::{ from_bytes, from_bytes_with_checksum, uasdls::{UASDatalinkLS, CRC}, }; const KLV_FRAME_DATA: &[u8] = &[ 0x06, 0x0e, 0x2b, 0x34, 0x02, 0x0b, 0x01, 0x01, 0x0e, 0x01, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x81, 0x91, 0x02, 0x08, 0x00, 0x04, 0x6c, 0x8e, 0x20, 0x03, 0x83, 0x85, 0x41, 0x01, 0x01, 0x05, 0x02, 0x3d, 0x3b, 0x06, 0x02, 0x15, 0x80, 0x07, 0x02, 0x01, 0x52, 0x0b, 0x03, 0x45, 0x4f, 0x4e, 0x0c, 0x0e, 0x47, 0x65, 0x6f, 0x64, 0x65, 0x74, 0x69, 0x63, 0x20, 0x57, 0x47, 0x53, 0x38, 0x34, 0x0d, 0x04, 0x4d, 0xc4, 0xdc, 0xbb, 0x0e, 0x04, 0xb1, 0xa8, 0x6c, 0xfe, 0x0f, 0x02, 0x1f, 0x4a, 0x10, 0x02, 0x00, 0x85, 0x11, 0x02, 0x00, 0x4b, 0x12, 0x04, 0x20, 0xc8, 0xd2, 0x7d, 0x13, 0x04, 0xfc, 0xdd, 0x02, 0xd8, 0x14, 0x04, 0xfe, 0xb8, 0xcb, 0x61, 0x15, 0x04, 0x00, 0x8f, 0x3e, 0x61, 0x16, 0x04, 0x00, 0x00, 0x01, 0xc9, 0x17, 0x04, 0x4d, 0xdd, 0x8c, 0x2a, 0x18, 0x04, 0xb1, 0xbe, 0x9e, 0xf4, 0x19, 0x02, 0x0b, 0x85, 0x28, 0x04, 0x4d, 0xdd, 0x8c, 0x2a, 0x29, 0x04, 0xb1, 0xbe, 0x9e, 0xf4, 0x2a, 0x02, 0x0b, 0x85, 0x38, 0x01, 0x2e, 0x39, 0x04, 0x00, 0x8d, 0xd4, 0x29, 0x01, 0x02, 0x1c, 0x5f, ]; fn bench_main(c: &mut Criterion) { c.bench_function("klv_parse_UASDLS_sample", |b| { b.iter(|| { let _x = from_bytes::(KLV_FRAME_DATA).unwrap(); }) }); c.bench_function("klv_parse_UASDLS_sample_with_checksum", |b| { b.iter(|| { let _x: UASDatalinkLS = from_bytes_with_checksum(KLV_FRAME_DATA, CRC {}).unwrap(); }) }); } criterion_group!(benches, bench_main); criterion_main!(benches);