use std::time::{Duration, Instant};
use super::session::Session;
const FRAMES: usize = 40;
fn median(mut times: Vec<Duration>) -> Duration {
times.sort();
times[times.len() / 2]
}
#[test]
#[ignore = "a measurement, not a test"]
fn patch_editor_frame_bench() {
let mut session = Session::with_fixtures(500);
let frame = median(
(0..FRAMES)
.map(|_| {
let start = Instant::now();
session.frame(vec![]);
start.elapsed()
})
.collect(),
);
let draft = session.draft();
let replaced = std::hint::black_box(false);
let checks = median(
(0..FRAMES)
.map(|_| {
let start = Instant::now();
std::hint::black_box(!replaced || draft.applied == session.project().patch);
std::hint::black_box(draft.status());
std::hint::black_box(draft.status());
start.elapsed()
})
.collect(),
);
println!("patch editor, 502 fixtures (median): frame {frame:?}, draft checks {checks:?}");
}