From 8d4cfa634104319d7c2877f50eea2cc43b135848 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 24 May 2023 16:57:14 +0000 Subject: [PATCH 1/2] Update criterion requirement from 0.3 to 0.5 Updates the requirements on [criterion](https://github.com/bheisler/criterion.rs) to permit the latest version. - [Changelog](https://github.com/bheisler/criterion.rs/blob/master/CHANGELOG.md) - [Commits](https://github.com/bheisler/criterion.rs/compare/0.3.0...0.5.0) --- updated-dependencies: - dependency-name: criterion dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 23ff754..b2ccd89 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ name = "rtp_rs" path = "src/lib.rs" [dev-dependencies] -criterion = "0.3" +criterion = "0.5" [[bench]] name = "bench" From 89afd74a998b34e0de5f331fc88da1865d96be52 Mon Sep 17 00:00:00 2001 From: David Holroyd Date: Mon, 11 Mar 2024 22:08:49 +0000 Subject: [PATCH 2/2] Updated Criterion API --- benches/bench.rs | 59 ++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/benches/bench.rs b/benches/bench.rs index 8fbfaf9..67ce4bf 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -40,42 +40,37 @@ fn rtp_reader(c: &mut Criterion) { 0xbcu8, 0x5fu8, 0x8eu8, 0x86u8, 0x56u8, 0x5au8, 0xfcu8, 0x7au8, 0x8bu8, 0xddu8, 0x9au8, 0x1cu8, 0xf6u8, 0xb4u8, 0x85u8, 0xf4u8, 0xb0u8, ]; - c.bench( - "parse", - Benchmark::new("parse", move |b| { - b.iter(|| { - let header = RtpReader::new(&data).unwrap(); - assert_eq!(2, header.version()); - assert!(header.padding().is_none()); - assert!(header.extension().is_none()); - assert_eq!(0, header.csrc_count()); - assert!(header.mark()); - assert_eq!(96, header.payload_type()); - assert_eq!(10040, u16::from(header.sequence_number())); - assert_eq!(1_692_665_255, header.timestamp()); - assert_eq!(0xa242_af01, header.ssrc()); - assert_eq!(379, header.payload().len()); - }); - }) - .throughput(Throughput::Bytes(data.len() as u64)), - ); + let mut group = c.benchmark_group("parse"); + group.throughput(Throughput::Bytes(data.len() as u64)); + group.bench_function("parse", move |b| { + b.iter(|| { + let header = RtpReader::new(&data).unwrap(); + assert_eq!(2, header.version()); + assert!(header.padding().is_none()); + assert!(header.extension().is_none()); + assert_eq!(0, header.csrc_count()); + assert!(header.mark()); + assert_eq!(96, header.payload_type()); + assert_eq!(10040, u16::from(header.sequence_number())); + assert_eq!(1_692_665_255, header.timestamp()); + assert_eq!(0xa242_af01, header.ssrc()); + assert_eq!(379, header.payload().len()); + }); + }); } fn rtp_builder(c: &mut Criterion) { let payload = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; - c.bench( - "builder", - Benchmark::new("builder", move |b| { - b.iter(|| { - let _result = RtpPacketBuilder::new() - .payload_type(12) - .payload(&payload) - .marked(true) - .add_csrc(12) - .build().unwrap(); - }); - }) - ); + c.bench_function("builder", move |b| { + b.iter(|| { + let _result = RtpPacketBuilder::new() + .payload_type(12) + .payload(&payload) + .marked(true) + .add_csrc(12) + .build().unwrap(); + }); + }); } criterion_group!(benches, rtp_reader, rtp_builder);