This commit is contained in:
Llywelwyn 2023-07-08 00:03:46 +01:00
parent 9d01ab220d
commit a79669d55c
4 changed files with 309 additions and 33 deletions

View file

@ -0,0 +1,16 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use rltk::RGB;
/// Benchmarks methods from rltk used to desaturate non-visible tiles.
// Greyscale is significantly faster, but generally looks worse - the
// third alternative is directly setting the desaturated value, if it
// is known in advance.
fn nonvisible_benchmark(c: &mut Criterion) {
let bg = black_box(RGB::from_f32(0.4, 0., 0.));
c.bench_function("rgb -> greyscale", |b| b.iter(|| bg.to_greyscale()));
c.bench_function("rgb -> desaturate", |b| b.iter(|| bg.desaturate()));
}
criterion_group!(benches, nonvisible_benchmark);
criterion_main!(benches);