-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
benchmarking: add bench for spectrum.rs
- Loading branch information
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,3 +48,7 @@ harness = false | |
[[bench]] | ||
name = "wavelength" | ||
harness = false | ||
|
||
[[bench]] | ||
name = "spectrum" | ||
harness = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))) | ||
} |