add initial benchmark tests for asset loading
only for gif bitmaps right now, since i want to (eventually) clean that up somewhat
This commit is contained in:
parent
ed754cb9ac
commit
a9610a5762
|
@ -30,3 +30,7 @@ harness = false
|
|||
[[bench]]
|
||||
name = "blit"
|
||||
harness = false
|
||||
|
||||
[[bench]]
|
||||
name = "loading"
|
||||
harness = false
|
||||
|
|
27
libretrogd/benches/loading.rs
Normal file
27
libretrogd/benches/loading.rs
Normal file
|
@ -0,0 +1,27 @@
|
|||
use std::io::Cursor;
|
||||
|
||||
use criterion::{black_box, Criterion, criterion_group, criterion_main};
|
||||
|
||||
use libretrogd::graphics::*;
|
||||
|
||||
pub static SMALL_GIF_FILE_BYTES: &[u8] = include_bytes!("../test-assets/test.gif");
|
||||
pub static LARGE_GIF_FILE_BYTES: &[u8] = include_bytes!("../test-assets/test_image.gif");
|
||||
|
||||
pub fn criterion_benchmark(c: &mut Criterion) {
|
||||
c.bench_function("loading_small_gif", |b| {
|
||||
b.iter(|| {
|
||||
let mut reader = Cursor::new(SMALL_GIF_FILE_BYTES);
|
||||
Bitmap::load_gif_bytes(black_box(&mut reader)).unwrap();
|
||||
})
|
||||
});
|
||||
|
||||
c.bench_function("loading_large_gif", |b| {
|
||||
b.iter(|| {
|
||||
let mut reader = Cursor::new(LARGE_GIF_FILE_BYTES);
|
||||
Bitmap::load_gif_bytes(black_box(&mut reader)).unwrap();
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
criterion_group!(benches, criterion_benchmark);
|
||||
criterion_main!(benches);
|
Loading…
Reference in a new issue