Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(editor): validate the playback benchmark press gap up front

Richie McIlroy09e309233aa7
diff --git a/crates/editor/examples/editor-playback-benchmark.rs b/crates/editor/examples/editor-playback-benchmark.rs
index 6c6c70e04..1405ccb61 100644
--- a/crates/editor/examples/editor-playback-benchmark.rs
+++ b/crates/editor/examples/editor-playback-benchmark.rs
@@ -467,6 +467,18 @@ async fn main() {
.map(|seconds| (seconds * fps as f64).round() as u32)
})
.unwrap_or(0);
+ // `--press-gap <secs>` idles between presses, e.g. to exercise the audio
+ // output's idle pause before the next play.
+ let press_gap = arg_value(&args, "--press-gap").map(|value| {
+ value
+ .parse::<f64>()
+ .ok()
+ .and_then(|secs| Duration::try_from_secs_f64(secs).ok())
+ .unwrap_or_else(|| {
+ eprintln!("--press-gap expects a non-negative number of seconds, got {value:?}");
+ std::process::exit(2);
+ })
+ });
println!("{}", "=".repeat(64));
println!(" CAP EDITOR LIVE PLAYBACK BENCHMARK");
@@ -583,12 +595,6 @@ async fn main() {
let mut summary = BenchmarkSummary::default();
let mut measured_elapsed = 0.0f64;
- // `--press-gap <secs>` idles between presses, e.g. to exercise the audio
- // output's idle pause before the next play.
- let press_gap = arg_value(&args, "--press-gap")
- .and_then(|s| s.parse::<f64>().ok())
- .map(Duration::from_secs_f64);
-
for (press_idx, (press_start_frame, press_frames)) in presses.iter().copied().enumerate() {
if press_idx > 0
&& let Some(gap) = press_gap