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