An export measurement may carry the sound it is judged by
Browse files at this commit56e406afe2aa55eb76a216e463e783bcec201fe0Parent: 522e89f- chore
- an export measurement may carry the sound it is judged by
2 changed files +38 -6
- crates/engine/examples/bench.rs +26 -5
- scripts/bench.sh +12 -1
crates/engine/examples/bench.rsmodified+26 -5
| @@ -23,7 +23,15 @@ | |||
| 23 | //! writing except the export destination it is handed. | 23 | //! writing except the export destination it is handed. |
| 24 | //! | 24 | //! |
| 25 | //! Env: `BENCH_TTFF_TIMEOUT` (s, default 180) how long a seek may wait for its | 25 | //! Env: `BENCH_TTFF_TIMEOUT` (s, default 180) how long a seek may wait for its |
| 26 | -//! first frame, `BENCH_EXPORT_CAP` (s, default 300) the wall clock any single | 26 | +//! first frame, `BENCH_EXPORT_SPAN` (s, default 60) how much timeline one |
| 27 | +//! export measurement covers, `BENCH_EXPORT_AUDIO` (unset) whether that | ||
| 28 | +//! timeline carries its source's sound as well -- the row is named `_av` when | ||
| 29 | +//! it does, because an export's wall clock is the audio pass plus the picture | ||
| 30 | +//! and a picture-only number is not the thing a person waits for -- | ||
| 31 | +//! `BENCH_EXPORT_ASTREAM` (default 0) which of the file's audio streams that | ||
| 32 | +//! is, a film's second track often being the one no sample table can copy and | ||
| 33 | +//! therefore the one that measures a re-encode, | ||
| 34 | +//! `BENCH_EXPORT_CAP` (s, default 300) the wall clock any single | ||
| 27 | //! export measurement may take, `BENCH_EXPORT_REPS` (default 5) how many times | 35 | //! export measurement may take, `BENCH_EXPORT_REPS` (default 5) how many times |
| 28 | //! an export is repeated *if the cap leaves room* -- a 4K encode gets one | 36 | //! an export is repeated *if the cap leaves room* -- a 4K encode gets one |
| 29 | //! capped rep, the small control gets five -- and `BENCH_KEEP` (unset) whether | 37 | //! capped rep, the small control gets five -- and `BENCH_KEEP` (unset) whether |
| @@ -364,7 +372,12 @@ fn export_bench(path: &Path, seat: &str, out_dir: &Path) { | |||
| 364 | "hevchw" => (Format::Hevc, false), | 372 | "hevchw" => (Format::Hevc, false), |
| 365 | _ => usage(), | 373 | _ => usage(), |
| 366 | }; | 374 | }; |
| 367 | - let metric = format!("export_fps_{seat}"); | 375 | + // The sound is opt-in and named in the row, so an `_av` number is never |
| 376 | + // compared against a picture-only one: what it measures is the *export* -- | ||
| 377 | + // audio pass, mux and all -- which is the only shape of the number a | ||
| 378 | + // "twice real time" claim may be made from. | ||
| 379 | + let with_audio = std::env::var_os("BENCH_EXPORT_AUDIO").is_some(); | ||
| 380 | + let metric = format!("export_fps_{seat}{}", if with_audio { "_av" } else { "" }); | ||
| 368 | let (meta, _) = match engine::demux::Demuxer::open(path) { | 381 | let (meta, _) = match engine::demux::Demuxer::open(path) { |
| 369 | Ok(opened) => opened, | 382 | Ok(opened) => opened, |
| 370 | Err(e) => { | 383 | Err(e) => { |
| @@ -372,7 +385,8 @@ fn export_bench(path: &Path, seat: &str, out_dir: &Path) { | |||
| 372 | return; | 385 | return; |
| 373 | } | 386 | } |
| 374 | }; | 387 | }; |
| 375 | - let span = ((meta.frame_rate * 60.0) as u32).min(meta.frame_count.max(1)); | 388 | + let span = ((meta.frame_rate * env_f64("BENCH_EXPORT_SPAN", 60.0)) as u32) |
| 389 | + .min(meta.frame_count.max(1)); | ||
| 376 | let in_frame = (meta.frame_count / 10).min(meta.frame_count.saturating_sub(span)); | 390 | let in_frame = (meta.frame_count / 10).min(meta.frame_count.saturating_sub(span)); |
| 377 | let clip = Clip { | 391 | let clip = Clip { |
| 378 | start: 0, | 392 | start: 0, |
| @@ -385,9 +399,16 @@ fn export_bench(path: &Path, seat: &str, out_dir: &Path) { | |||
| 385 | fit: engine::scale::FitPolicy::default(), | 399 | fit: engine::scale::FitPolicy::default(), |
| 386 | speed: Speed::NORMAL, | 400 | speed: Speed::NORMAL, |
| 387 | }; | 401 | }; |
| 402 | + // The sound, where it was asked for, is the same clip on an audio lane: | ||
| 403 | + // the very window the picture covers, so the two passes measure one export. | ||
| 404 | + let mut lanes = vec![(LaneKind::Video, vec![clip.clone()])]; | ||
| 405 | + if with_audio { | ||
| 406 | + lanes.push((LaneKind::Audio, vec![clip])); | ||
| 407 | + } | ||
| 408 | + let stream = env_f64("BENCH_EXPORT_ASTREAM", 0.0) as usize; | ||
| 388 | let project = match Project::from_parts( | 409 | let project = match Project::from_parts( |
| 389 | - vec![Source::new(path, 0)], | 410 | + vec![Source::new(path, stream)], |
| 390 | - vec![(LaneKind::Video, vec![clip])], | 411 | + lanes, |
| 391 | Vec::new(), | 412 | Vec::new(), |
| 392 | Vec::new(), | 413 | Vec::new(), |
| 393 | ) { | 414 | ) { |
scripts/bench.shmodified+12 -1
| @@ -41,8 +41,19 @@ LOG="$OUT_DIR/bench.log" | |||
| 41 | # Absolute, because $CARGO_TARGET_DIR may already be one and the plugin path | 41 | # Absolute, because $CARGO_TARGET_DIR may already be one and the plugin path |
| 42 | # below must not become "$PWD/$HOME/...". | 42 | # below must not become "$PWD/$HOME/...". |
| 43 | TARGET=$(realpath -m "${CARGO_TARGET_DIR:-target}") | 43 | TARGET=$(realpath -m "${CARGO_TARGET_DIR:-target}") |
| 44 | -cargo build --release -p engine -p engine-hw --example bench || exit 1 | 44 | +# Two builds, and that is not tidiness: `--example bench` is a target filter, |
| 45 | +# and engine-hw has no example by that name, so one command builds the harness | ||
| 46 | +# and *not the plugin* -- a fresh target directory then benchmarks pure | ||
| 47 | +# software while every row says nothing about it (measured 2026-08-13: the | ||
| 48 | +# film's hardware export read 11.55 fps, and 94.58 fps once the plugin was | ||
| 49 | +# there). | ||
| 50 | +cargo build --release -p engine-hw || exit 1 | ||
| 51 | +cargo build --release -p engine --example bench || exit 1 | ||
| 45 | BENCH="$TARGET/release/examples/bench" | 52 | BENCH="$TARGET/release/examples/bench" |
| 53 | +[ -f "$TARGET/release/libengine_hw.so" ] || { | ||
| 54 | + echo "no libengine_hw.so in $TARGET/release: every hardware row would be software" >&2 | ||
| 55 | + exit 1 | ||
| 56 | +} | ||
| 46 | # The plugin is looked for beside the running executable, and an example binary | 57 | # The plugin is looked for beside the running executable, and an example binary |
| 47 | # lives one directory below the plugin: without this, hardware decode and | 58 | # lives one directory below the plugin: without this, hardware decode and |
| 48 | # hardware encode silently fall back to software and the baseline is a lie. | 59 | # hardware encode silently fall back to software and the baseline is a lie. |