Skip to content

Commit

Permalink
benchmarking: add bench for spectrum.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
Walther committed Feb 4, 2024
1 parent d65c3e6 commit 7700896
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions clovers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@ harness = false
[[bench]]
name = "wavelength"
harness = false

[[bench]]
name = "spectrum"
harness = false
24 changes: 24 additions & 0 deletions clovers/benches/spectrum.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use clovers::spectrum::*;
use clovers::wavelength::*;
use divan::black_box;
use palette::white_point::E;
use palette::Xyz;
use rand::rngs::SmallRng;
use rand::Rng;
use rand::SeedableRng;

fn main() {
divan::main();
}

#[divan::bench]
fn xyz_to_p(bencher: divan::Bencher) {
bencher
.with_inputs(|| {
let mut rng = SmallRng::from_entropy();
let wave = random_wavelength(&mut rng);
let xyz: Xyz<E> = Xyz::new(rng.gen(), rng.gen(), rng.gen());
(wave, xyz)
})
.bench_values(|(wave, xyz)| black_box(spectrum_xyz_to_p(wave, xyz)))
}

0 comments on commit 7700896

Please sign in to comment.