Add benches/ directory referenced in Cargo.toml.
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Bill Thiede 2019-06-22 07:42:33 -07:00
parent eae77f0ccb
commit 6f3e29a648

37
rtiow/benches/spheres.rs Normal file
View File

@ -0,0 +1,37 @@
#[macro_use]
extern crate criterion;
use criterion::Criterion;
use criterion::ParameterizedBenchmark;
use rtiow::hitable::Hit;
use rtiow::material::Lambertian;
use rtiow::ray::Ray;
use rtiow::sphere::Sphere;
use rtiow::texture::ConstantTexture;
use rtiow::vec3::Vec3;
fn criterion_benchmark(c: &mut Criterion) {
let sphere = Sphere::new(
Vec3::new(0., 0., 0.),
1.,
Lambertian::new(ConstantTexture::new([1., 0., 0.])),
);
let rays = vec![
// Hit
Ray::new([0., 0., -2.], [0., 0., 1.], 0.),
// Miss
Ray::new([0., 0., -2.], [0., 0., -1.], 0.),
];
c.bench(
"sphere",
ParameterizedBenchmark::new(
"Sphere",
move |b, r| b.iter(|| sphere.hit(*r, 0., 1.)),
rays,
),
);
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);