File: parse_response.rs

package info (click to toggle)
rust-mpd-protocol 1.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 188 kB
  • sloc: makefile: 2
file content (18 lines) | stat: -rw-r--r-- 587 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use mpd_protocol::Connection;

// NOTE: Benchmark requires `--cfg criterion` to be set to build correctly.

const LONG_RESPONSE: &[u8] = include_bytes!("long.response");

pub fn criterion_benchmark(c: &mut Criterion) {
    c.bench_function("long response", |b| {
        b.iter(|| {
            let mut connection = Connection::new_internal(black_box(LONG_RESPONSE));
            let _ = connection.receive().unwrap();
        })
    });
}

criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);