Add a simple benchmark for bounding_box
authorBernie Innocenti <bernie@codewiz.org>
Sat, 6 May 2017 03:27:14 +0000 (23:27 -0400)
committerBernie Innocenti <bernie@codewiz.org>
Sat, 6 May 2017 03:27:14 +0000 (23:27 -0400)
benches/bounding_box.rs [new file with mode: 0644]
support/camera.rs

diff --git a/benches/bounding_box.rs b/benches/bounding_box.rs
new file mode 100644 (file)
index 0000000..277435c
--- /dev/null
@@ -0,0 +1,30 @@
+#![feature(test)]
+
+extern crate mandelwow_lib;
+extern crate glutin;
+#[macro_use(uniform)]
+extern crate glium;
+extern crate test;
+
+use mandelwow_lib::Cube;
+use mandelwow_lib::bounding_box::*;
+use glium::DisplayBuild;
+
+#[bench]
+fn bench_bounding_box(b: &mut test::Bencher) {
+    let display = glutin::WindowBuilder::new().build_glium().unwrap();
+    let program = solid_fill_program(&display);
+    let bounds = Cube { xmin: -2., xmax: 0.7, ymin: -1., ymax:  1., zmin: -1.1, zmax:  1.1 };
+    let bbox = BoundingBox::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,
+            view: mat,
+            perspective: mat,
+        };
+        bbox.draw(&mut frame, &uniforms);
+    });
+    frame.finish().unwrap();
+}
index fe1398d874ee3842a0006ee668ddde8f2002c780..809ffcb93991bcb464a28966ac53f862ffe27de8 100644 (file)
@@ -37,7 +37,7 @@ pub struct CameraState {
 impl CameraState {
     pub fn new() -> CameraState {
         CameraState {
-            aspect_ratio: 1024.0 / 768.0,
+            aspect_ratio: 600.0 / 600.0,
             pos: Vec3(0.0, 0.0, 0.0),
             dir: Vec3(0.0, 0.0, -1.0),
             .. Default::default()