1use std::time::Instant;
9
10use supergrafx_rust::trace::SgxSetup;
11
12fn main() {
13 let args: Vec<String> = std::env::args().skip(1).collect();
14 let setup = match SgxSetup::parse(&args) {
15 Ok(setup) => setup,
16 Err(error) => {
17 eprintln!("sgx-bench: {error}");
18 std::process::exit(1);
19 }
20 };
21 let mut system = setup.build().expect("a board");
22 let began = Instant::now();
23 let mut samples = 0;
24 for _ in 0..setup.base.frames {
25 setup.before_frame(&mut system);
26 system.run_frame();
27 samples += system.board_mut().take_audio().len();
28 }
29 let seconds = began.elapsed().as_secs_f64();
30 println!(
31 "{} frames in {:.3} s: {:.1} frames per second ({} audio samples, mclk {})",
32 setup.base.frames,
33 seconds,
34 setup.base.frames as f64 / seconds,
35 samples,
36 system.board().mclk
37 );
38 if let Some(page) = supergrafx_rust::video_page(system.board_mut()) {
39 let vpc = &page.vpc;
40 println!(
41 "VPC ${:02X} ${:02X}, windows ${:03X} ${:03X}, ST0-ST2 to VDC {}",
42 vpc.priority[0],
43 vpc.priority[1],
44 vpc.window[0],
45 vpc.window[1],
46 if vpc.st_to_vdc2 { 2 } else { 1 }
47 );
48 }
49}