Skip to content

Commit

Permalink
chore: Add more benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
manokara committed Nov 11, 2020
1 parent b9b7bec commit 84e4198
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
22 changes: 20 additions & 2 deletions benches/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
})
Expand Down
1 change: 1 addition & 0 deletions data/max_depth.benc
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions data/really_deep.benc
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 84e4198

Please sign in to comment.