Debian Codegraph @

third_party/rust/neqo-transport/benches/rx_stream_orderer.rs

raw
1 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
2 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
3 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
4 // option. This file may not be copied, modified, or distributed
5 // except according to those terms.
6
7 use std::{hint::black_box, time::Duration};
8
9 use criterion::{criterion_group, criterion_main, Criterion};
10 use neqo_transport::recv_stream::RxStreamOrderer;
11
12 fn rx_stream_orderer() {
13 let mut rx = RxStreamOrderer::new();
14 let data: &[u8] = &[0; 1337];
15
16 for i in 0..100_000 {
17 rx.inbound_frame(i * 1337, data);
18 }
19 }
20
21 fn criterion_benchmark(c: &mut Criterion) {
22 c.bench_function("RxStreamOrderer::inbound_frame()", |b| {
23 b.iter(black_box(rx_stream_orderer));
24 });
25 }
26
27 criterion_group! {
28 name = benches;
29 config = Criterion::default().warm_up_time(Duration::from_secs(5)).measurement_time(Duration::from_secs(60));
30 targets = criterion_benchmark
31 }
32 criterion_main!(benches);