Skip to content

Commit 0623db1

Browse files
committed
Add benchmark for decompressing logic
1 parent 2b9e9d9 commit 0623db1

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

benches/main.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use std::path::Path;
1+
use std::{fs::File, io::Read, path::Path};
22

33
use criterion::{black_box, criterion_group, criterion_main, Criterion};
44

5-
use base_sequence_compression::compress_fasta;
5+
use base_sequence_compression::{compress_fasta, decompress_fasta};
66

77
fn criterion_benchmark(c: &mut Criterion) {
88
c.bench_function("Compress Small FASTA file", |b| {
@@ -19,6 +19,24 @@ fn criterion_benchmark(c: &mut Criterion) {
1919
compress_fasta(black_box(&content));
2020
})
2121
});
22+
c.bench_function("Decompress Small FASTA file", |b| {
23+
b.iter(|| {
24+
let path = Path::new("benches/output/test.bin");
25+
let mut file = File::open(path).ok().unwrap();
26+
let mut content = Vec::new();
27+
file.read_to_end(black_box(&mut content)).ok();
28+
decompress_fasta(black_box(&content));
29+
})
30+
});
31+
c.bench_function("Decompress Large FASTA file", |b| {
32+
b.iter(|| {
33+
let path = Path::new("benches/output/large.bin");
34+
let mut file = File::open(path).ok().unwrap();
35+
let mut content = Vec::new();
36+
file.read_to_end(black_box(&mut content)).ok();
37+
decompress_fasta(black_box(&content));
38+
})
39+
});
2240
}
2341

2442
criterion_group!(benches, criterion_benchmark);

benches/output/large.bin

76.4 KB
Binary file not shown.

benches/output/test.bin

44 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)