Add a simple benchmark for bounding_box
[mandelwow.git] / benches / bounding_box.rs
1 #![feature(test)]
2
3 extern crate mandelwow_lib;
4 extern crate glutin;
5 #[macro_use(uniform)]
6 extern crate glium;
7 extern crate test;
8
9 use mandelwow_lib::Cube;
10 use mandelwow_lib::bounding_box::*;
11 use glium::DisplayBuild;
12
13 #[bench]
14 fn bench_bounding_box(b: &mut test::Bencher) {
15     let display = glutin::WindowBuilder::new().build_glium().unwrap();
16     let program = solid_fill_program(&display);
17     let bounds = Cube { xmin: -2., xmax: 0.7, ymin: -1., ymax:  1., zmin: -1.1, zmax:  1.1 };
18     let bbox = BoundingBox::new(&display, &bounds, &program);
19     let mut frame = display.draw();
20     b.iter(|| {
21         let mat = [[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.0f32]];
22         let uniforms = uniform! {
23             model: mat,
24             view: mat,
25             perspective: mat,
26         };
27         bbox.draw(&mut frame, &uniforms);
28     });
29     frame.finish().unwrap();
30 }