diff --git a/clovers/Cargo.toml b/clovers/Cargo.toml index 8fb007f9..dca5e57b 100644 --- a/clovers/Cargo.toml +++ b/clovers/Cargo.toml @@ -48,3 +48,7 @@ harness = false [[bench]] name = "wavelength" harness = false + +[[bench]] +name = "spectrum" +harness = false diff --git a/clovers/benches/spectrum.rs b/clovers/benches/spectrum.rs new file mode 100644 index 00000000..76e5de0e --- /dev/null +++ b/clovers/benches/spectrum.rs @@ -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 = Xyz::new(rng.gen(), rng.gen(), rng.gen()); + (wave, xyz) + }) + .bench_values(|(wave, xyz)| black_box(spectrum_xyz_to_p(wave, xyz))) +}