forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

perf.rs46 lines, 1.6 KiBHistoryRawDownload
1//! Throughput of 1080p 4:2:2 HQ (ffmpeg-encoded, light noise so the entropy coder has work).
2//! Prints fps for 1 and 4 threads; set `EC_PRORES_MIN_FPS` to assert the single-thread rate.
3
4mod common;
5use common::*;
6
7#[test]
8fn hd_hq_throughput() {
9 if !ffmpeg_or_skip() {
10 return;
11 }
12 let dir = scratch("perf");
13 let mov = dir.join("hd.mov");
14 assert!(run(&[
15 "-f", "lavfi", "-i", "testsrc2=size=1920x1080:rate=25,noise=alls=12:allf=t",
16 "-frames:v", "24", "-c:v", "prores_ks", "-profile", "3", "-pix_fmt", "yuv422p10le",
17 mov.to_str().unwrap(),
18 ]));
19 let bytes = std::fs::read(&mov).unwrap();
20 let pk = packets(&bytes);
21 let mut single = 0.0;
22 for threads in [1usize, 4] {
23 let mut dec = decoder(threads);
24 // Warm up, then best of 10 passes.
25 for p in &pk {
26 dec.decode(p).unwrap();
27 }
28 let mut best = f64::MAX;
29 for _ in 0..10 {
30 let t0 = std::time::Instant::now();
31 for p in &pk {
32 std::hint::black_box(dec.decode(p).unwrap());
33 }
34 best = best.min(t0.elapsed().as_secs_f64());
35 }
36 let fps = pk.len() as f64 / best;
37 eprintln!("1080p 422 HQ, {} bytes/frame, {threads} thread(s): {fps:.1} fps", bytes.len() / pk.len());
38 if threads == 1 {
39 single = fps;
40 }
41 }
42 if let Some(min) = std::env::var("EC_PRORES_MIN_FPS").ok().and_then(|v| v.parse::<f64>().ok()) {
43 assert!(single >= min, "single-thread {single:.1} fps below {min}");
44 }
45 let _ = std::fs::remove_dir_all(dir);
46}