diff --git a/benches/load.rs b/benches/load.rs index c3765c9..14ea75d 100644 --- a/benches/load.rs +++ b/benches/load.rs @@ -2,11 +2,29 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion}; use std::fs::File; const TORRENT_PATH: &'static str = concat!(env!("CARGO_MANIFEST_DIR"), "/data/torrent.benc"); +const DEEP1_PATH: &'static str = concat!(env!("CARGO_MANIFEST_DIR"), "/data/max_depth.benc"); +const DEEP2_PATH: &'static str = concat!(env!("CARGO_MANIFEST_DIR"), "/data/really_deep.benc"); pub fn load(c: &mut Criterion) { - let mut file = File::open(TORRENT_PATH).unwrap(); - c.bench_function("load torrent file", |b| { + let mut file = File::open(TORRENT_PATH).unwrap(); + + b.iter(|| { + bencode::load(black_box(&mut file)).expect("Failed loading file"); + }) + }); + + c.bench_function("load max depth", |b| { + let mut file = File::open(DEEP1_PATH).unwrap(); + + b.iter(|| { + bencode::load(black_box(&mut file)).expect("Failed loading file"); + }) + }); + + c.bench_function("load really deep", |b| { + let mut file = File::open(DEEP2_PATH).unwrap(); + b.iter(|| { bencode::load(black_box(&mut file)).expect("Failed loading file"); }) diff --git a/data/max_depth.benc b/data/max_depth.benc new file mode 100644 index 0000000..2dce9ed --- /dev/null +++ b/data/max_depth.benc @@ -0,0 +1 @@ +d3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:foodeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee \ No newline at end of file diff --git a/data/really_deep.benc b/data/really_deep.benc new file mode 100644 index 0000000..70e2d0f --- /dev/null +++ b/data/really_deep.benc @@ -0,0 +1 @@ +d3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:food3:foodeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee \ No newline at end of file