Skip to content

Commit

Permalink
Update criterion requirement from 0.3 to 0.5 (#9)
Browse files Browse the repository at this point in the history
* 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](bheisler/criterion.rs@0.3.0...0.5.0)

---
updated-dependencies:
- dependency-name: criterion
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>

* Updated Criterion API

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: David Holroyd <[email protected]>
  • Loading branch information
dependabot[bot] and dholroyd authored Mar 11, 2024
1 parent 65202ee commit 1cb8ef4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ name = "rtp_rs"
path = "src/lib.rs"

[dev-dependencies]
criterion = "0.3"
criterion = "0.5"

[[bench]]
name = "bench"
Expand Down
59 changes: 27 additions & 32 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1cb8ef4

Please sign in to comment.