kms: Optimize frame scheduling

This commit is contained in:
Victoria Brekenfeld 2024-02-14 17:46:33 +01:00 committed by Victoria Brekenfeld
parent 96518a9f29
commit db27fa483d
2 changed files with 16 additions and 12 deletions

View file

@ -905,7 +905,7 @@ pub struct Frame {
}
impl Frame {
fn render_time(&self) -> Duration {
fn _render_time(&self) -> Duration {
self.duration_elements + self.duration_render
}
@ -1028,11 +1028,12 @@ impl Fps {
self.frames.iter().map(|f| f.frame_time()).sum::<Duration>() / (self.frames.len() as u32)
}
pub fn avg_rendertime(&self, window: usize) -> Duration {
pub fn avg_time_to_display(&self, window: usize) -> Duration {
self.frames
.iter()
.rev()
.take(window)
.map(|f| f.render_time())
.map(|f| f.time_to_display())
.sum::<Duration>()
/ window as u32
}