forge
Explore
Log in

Don't you dare go Hollow

edith

Clone
★ 0

0 watching0 forksRust18.3 MiBfbc29d1Tahinli2 months ago972 commits

drop_cost.rs28 lines, 1.0 KiBHistoryRawDownload
1//! Scratch: how long a PlaybackSession takes to drop now that it joins its
2//! decode worker. Worst case is what a UI scrub pays per abandoned session.
3use std::time::Instant;
4
5fn main() {
6 let path = concat!(env!("CARGO_MANIFEST_DIR"), "/../../assets/test_av.mp4");
7 let mut worst = 0f64;
8 for i in 0..20 {
9 let session = engine::PlaybackSession::open(path).expect("open");
10 let t = Instant::now();
11 drop(session);
12 let ms = t.elapsed().as_secs_f64() * 1000.0;
13 worst = worst.max(ms);
14 eprintln!("run {i}: drop {ms:.1} ms");
15 }
16 eprintln!("worst drop: {worst:.1} ms");
17
18 // The scrub path: every seek now joins the worker it replaces.
19 let mut session = engine::PlaybackSession::open(path).expect("open");
20 let mut worst_seek = 0f64;
21 for i in 0..20 {
22 let t = Instant::now();
23 session.seek(f64::from(i) * 0.2);
24 let ms = t.elapsed().as_secs_f64() * 1000.0;
25 worst_seek = worst_seek.max(ms);
26 }
27 eprintln!("worst seek: {worst_seek:.1} ms");
28}