Fix calculation of wallclock time in the NanoVG demo

This commit is contained in:
Patrick Walton 2020-04-09 18:01:12 -07:00
parent 47919db8f3
commit ca36fed47b
1 changed files with 4 additions and 4 deletions

View File

@ -1318,7 +1318,7 @@ fn main() {
&demo_data);
// Render performance graphs.
let frame_elapsed_time = (Instant::now() - frame_start_time).as_secs_f32();
let cpu_frame_elapsed_time = (Instant::now() - frame_start_time).as_secs_f32();
fps_graph.render(&mut context, vec2f(5.0, 5.0));
cpu_graph.render(&mut context, vec2f(210.0, 5.0));
gpu_graph.render(&mut context, vec2f(415.0, 5.0));
@ -1330,10 +1330,10 @@ fn main() {
// Add stats to performance graphs.
if let Some(gpu_time) = renderer.shift_rendering_time() {
let cpu_time = renderer.stats.cpu_build_time.as_secs_f32() + frame_elapsed_time;
let cpu_build_time = renderer.stats.cpu_build_time.as_secs_f32();
let gpu_time = gpu_time.gpu_time.as_secs_f32();
fps_graph.push(cpu_time.max(gpu_time));
cpu_graph.push(cpu_time);
fps_graph.push(cpu_frame_elapsed_time + cpu_build_time.max(gpu_time));
cpu_graph.push(cpu_frame_elapsed_time + cpu_build_time);
gpu_graph.push(gpu_time);
}