mirror of
https://github.com/storytold/soundcraft.git
synced 2026-10-28 04:26:51 -06:00
examples/bounce_bench drives file.bounce_mix on the built-in demo session (the same path the
Bounce dialog and soundcraft-cli --bounce use) and prints per-run wall time, so export speed can
be measured and compared between builds:
cargo run --release -p soundcraft-engine --example bounce_bench -- OUT.wav [reps] [JSON params]
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
34 lines
1.2 KiB
Rust
34 lines
1.2 KiB
Rust
use serde_json::{Value, json};
|
|
use std::time::Instant;
|
|
|
|
fn main() {
|
|
let args: Vec<String> = std::env::args().skip(1).collect();
|
|
let Some(out) = args.first() else {
|
|
eprintln!("usage: bounce_bench OUT.wav [reps] [JSON params]");
|
|
std::process::exit(2);
|
|
};
|
|
let reps = args.get(1).and_then(|r| r.parse().ok()).unwrap_or(5usize);
|
|
let mut params = args.get(2).and_then(|p| serde_json::from_str::<Value>(p).ok()).unwrap_or_else(|| json!({}));
|
|
if let Some(m) = params.as_object_mut() {
|
|
m.insert("path".into(), json!(out));
|
|
}
|
|
let mut e = soundcraft_engine::demo::demo_engine();
|
|
let mut times = Vec::new();
|
|
let mut last = Value::Null;
|
|
for _ in 0..reps {
|
|
let t0 = Instant::now();
|
|
match e.execute("file.bounce_mix", ¶ms) {
|
|
Ok(v) => last = v,
|
|
Err(err) => {
|
|
eprintln!("bounce failed: {err}");
|
|
std::process::exit(1);
|
|
}
|
|
}
|
|
times.push(t0.elapsed().as_secs_f64());
|
|
}
|
|
let total: f64 = times.iter().sum();
|
|
let min = times.iter().copied().fold(f64::INFINITY, f64::min);
|
|
println!("{last}");
|
|
println!("total {total:.4} s, min {min:.4} s over {reps} bounces");
|
|
}
|