From 3180f30c5e35b34cc2e99f9b1e37da7eae56ed5c Mon Sep 17 00:00:00 2001 From: Bernie Innocenti Date: Sun, 7 May 2017 23:10:17 -0400 Subject: [PATCH] Add a benchmark for ShadedCube. --- benches/bounding_box.rs | 2 +- benches/shaded_cube.rs | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 benches/shaded_cube.rs diff --git a/benches/bounding_box.rs b/benches/bounding_box.rs index 277435c..597f215 100644 --- a/benches/bounding_box.rs +++ b/benches/bounding_box.rs @@ -6,9 +6,9 @@ extern crate glutin; extern crate glium; extern crate test; +use glium::DisplayBuild; use mandelwow_lib::Cube; use mandelwow_lib::bounding_box::*; -use glium::DisplayBuild; #[bench] fn bench_bounding_box(b: &mut test::Bencher) { diff --git a/benches/shaded_cube.rs b/benches/shaded_cube.rs new file mode 100644 index 0000000..8ea5a0e --- /dev/null +++ b/benches/shaded_cube.rs @@ -0,0 +1,29 @@ +#![feature(test)] + +extern crate mandelwow_lib; +#[macro_use(uniform)] +extern crate glium; +extern crate glutin; +extern crate test; + +use glium::DisplayBuild; +use mandelwow_lib::Cube; +use mandelwow_lib::shaded_cube::*; + +#[bench] +fn bench_shaded_cube(b: &mut test::Bencher) { + let display = glutin::WindowBuilder::new().build_glium().unwrap(); + let program = shaded_program(&display); + let bounds = Cube { xmin: -2., xmax: 0.7, ymin: -1., ymax: 1., zmin: -1.1, zmax: 1.1 }; + let cube = ShadedCube::new(&display, &bounds, &program); + let mut frame = display.draw(); + b.iter(|| { + let mat = [[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.0f32]]; + let uniforms = uniform! { + model: mat, + viewpersp: mat, + }; + cube.draw(&mut frame, &uniforms); + }); + frame.finish().unwrap(); +} -- 2.25.1