From 75e866a1a0061f8736fe253407db66c2f01895b0 Mon Sep 17 00:00:00 2001 From: ishanjain28 Date: Sun, 8 Mar 2020 22:02:03 +0530 Subject: [PATCH] log time taken to render a scene --- src/main.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main.rs b/src/main.rs index 00f24b7..245df70 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,6 +13,7 @@ use { keyboard::Keycode, pixels::PixelFormatEnum, }, + std::time::Instant, }; const NUM_SAMPLES: u8 = 100; @@ -100,7 +101,14 @@ fn main() -> Result<(), String> { }; } if should_update { + let now = Instant::now(); active_demo.render(&mut buffer, width, height, NUM_SAMPLES); + println!( + "Demo {} Time Taken(s) = {}", + active_demo.name(), + now.elapsed().as_secs_f64() + ); + texture.update(None, &buffer, width * 4).unwrap(); canvas.copy(&texture, None, None).unwrap(); canvas.present();