log time taken to render a scene

This commit is contained in:
Ishan Jain 2020-03-08 22:02:03 +05:30
parent 95eebf21b4
commit 75e866a1a0

View File

@ -13,6 +13,7 @@ use {
keyboard::Keycode, keyboard::Keycode,
pixels::PixelFormatEnum, pixels::PixelFormatEnum,
}, },
std::time::Instant,
}; };
const NUM_SAMPLES: u8 = 100; const NUM_SAMPLES: u8 = 100;
@ -100,7 +101,14 @@ fn main() -> Result<(), String> {
}; };
} }
if should_update { if should_update {
let now = Instant::now();
active_demo.render(&mut buffer, width, height, NUM_SAMPLES); 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(); texture.update(None, &buffer, width * 4).unwrap();
canvas.copy(&texture, None, None).unwrap(); canvas.copy(&texture, None, None).unwrap();
canvas.present(); canvas.present();