mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-09 12:21:31 +11:00
[frame_stats] Key binding to clear min/max frame time; address review comments
This commit is contained in:
parent
1ac4a4f1a8
commit
306aeab6df
|
@ -19,4 +19,5 @@ $ cargo run -p with_winit --release -- [SVG FILES]
|
||||||
- Arrow keys switch between SVG images in the current set.
|
- Arrow keys switch between SVG images in the current set.
|
||||||
- Space resets the position and zoom of the image.
|
- Space resets the position and zoom of the image.
|
||||||
- S toggles the frame statistics layer
|
- S toggles the frame statistics layer
|
||||||
|
- C resets the min/max frame time tracked by statistics
|
||||||
- Escape exits the program.
|
- Escape exits the program.
|
||||||
|
|
|
@ -99,7 +99,7 @@ fn run(
|
||||||
let mut simple_text = SimpleText::new();
|
let mut simple_text = SimpleText::new();
|
||||||
let mut images = ImageCache::new();
|
let mut images = ImageCache::new();
|
||||||
let mut stats = stats::Stats::new();
|
let mut stats = stats::Stats::new();
|
||||||
let mut stats_toggle = true;
|
let mut stats_shown = true;
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
|
|
||||||
let mut touch_state = multi_touch::TouchState::new();
|
let mut touch_state = multi_touch::TouchState::new();
|
||||||
|
@ -146,7 +146,10 @@ fn run(
|
||||||
transform = Affine::IDENTITY;
|
transform = Affine::IDENTITY;
|
||||||
}
|
}
|
||||||
Some(VirtualKeyCode::S) => {
|
Some(VirtualKeyCode::S) => {
|
||||||
stats_toggle = !stats_toggle;
|
stats_shown = !stats_shown;
|
||||||
|
}
|
||||||
|
Some(VirtualKeyCode::C) => {
|
||||||
|
stats.clear_min_and_max();
|
||||||
}
|
}
|
||||||
Some(VirtualKeyCode::Escape) => {
|
Some(VirtualKeyCode::Escape) => {
|
||||||
*control_flow = ControlFlow::Exit;
|
*control_flow = ControlFlow::Exit;
|
||||||
|
@ -304,7 +307,7 @@ fn run(
|
||||||
transform = transform * Affine::scale(scale_factor);
|
transform = transform * Affine::scale(scale_factor);
|
||||||
}
|
}
|
||||||
builder.append(&fragment, Some(transform));
|
builder.append(&fragment, Some(transform));
|
||||||
if stats_toggle {
|
if stats_shown {
|
||||||
snapshot.draw_layer(
|
snapshot.draw_layer(
|
||||||
&mut builder,
|
&mut builder,
|
||||||
&mut scene_params.text,
|
&mut scene_params.text,
|
||||||
|
|
|
@ -168,6 +168,11 @@ impl Stats {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn clear_min_and_max(&mut self) {
|
||||||
|
self.min = u64::MAX;
|
||||||
|
self.max = u64::MIN;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn add_sample(&mut self, sample: Sample) {
|
pub fn add_sample(&mut self, sample: Sample) {
|
||||||
let oldest = if self.count < SLIDING_WINDOW_SIZE {
|
let oldest = if self.count < SLIDING_WINDOW_SIZE {
|
||||||
self.count += 1;
|
self.count += 1;
|
||||||
|
@ -181,11 +186,7 @@ impl Stats {
|
||||||
if let Some(oldest) = oldest {
|
if let Some(oldest) = oldest {
|
||||||
self.sum -= oldest;
|
self.sum -= oldest;
|
||||||
}
|
}
|
||||||
if micros < self.min {
|
self.min = self.min.min(micros);
|
||||||
self.min = micros;
|
self.max = self.max.max(micros);
|
||||||
}
|
|
||||||
if micros > self.max {
|
|
||||||
self.max = micros;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue