Add simple fps benchmark
Former-commit-id: d4bb368fa0b5ab98819aa509f799e96a4da58308
This commit is contained in:
parent
519f4d6bb4
commit
1e9cf89cb1
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -461,6 +461,13 @@ dependencies = [
|
|||
"yansi 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fps_bench"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"rustboyadvance-core 0.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fuchsia-cprng"
|
||||
version = "0.1.1"
|
||||
|
|
|
@ -4,6 +4,7 @@ members = [
|
|||
"platform/rustboyadvance-sdl2",
|
||||
"platform/rustboyadvance-minifb",
|
||||
"bindings/rustboyadvance-jni",
|
||||
"fps_bench"
|
||||
]
|
||||
|
||||
[profile.dev]
|
||||
|
|
8
fps_bench/Cargo.toml
Normal file
8
fps_bench/Cargo.toml
Normal file
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "fps_bench"
|
||||
version = "0.1.0"
|
||||
authors = ["Michel Heily <michelheily@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
rustboyadvance-core = {path = "../rustboyadvance-core/"}
|
58
fps_bench/src/main.rs
Normal file
58
fps_bench/src/main.rs
Normal file
|
@ -0,0 +1,58 @@
|
|||
use std::cell::RefCell;
|
||||
use std::env;
|
||||
use std::path::Path;
|
||||
use std::rc::Rc;
|
||||
|
||||
use rustboyadvance_core::prelude::*;
|
||||
use rustboyadvance_core::util::FpsCounter;
|
||||
|
||||
struct BenchmarkHardware {}
|
||||
|
||||
impl BenchmarkHardware {
|
||||
fn new() -> BenchmarkHardware {
|
||||
BenchmarkHardware {}
|
||||
}
|
||||
}
|
||||
|
||||
impl VideoInterface for BenchmarkHardware {}
|
||||
impl AudioInterface for BenchmarkHardware {}
|
||||
impl InputInterface for BenchmarkHardware {}
|
||||
|
||||
fn main() {
|
||||
if env::args().count() < 3 {
|
||||
eprintln!("usage: {} <bios> <rom>", env::args().nth(0).unwrap());
|
||||
return;
|
||||
}
|
||||
|
||||
let bios_path = env::args().nth(1).expect("missing <bios>");
|
||||
let rom_path = env::args().nth(2).expect("missing <rom>");
|
||||
|
||||
let bios = read_bin_file(Path::new(&bios_path)).expect("failed to read bios file");
|
||||
let rom = read_bin_file(Path::new(&rom_path)).expect("failed to read rom file");
|
||||
|
||||
let gamepak = GamepakBuilder::new()
|
||||
.take_buffer(rom.into_boxed_slice())
|
||||
.with_sram()
|
||||
.without_backup_to_file()
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
let dummy = Rc::new(RefCell::new(BenchmarkHardware::new()));
|
||||
|
||||
let mut gba = GameBoyAdvance::new(
|
||||
bios.into_boxed_slice(),
|
||||
gamepak,
|
||||
dummy.clone(),
|
||||
dummy.clone(),
|
||||
dummy.clone(),
|
||||
);
|
||||
gba.skip_bios();
|
||||
|
||||
let mut fps_counter = FpsCounter::default();
|
||||
loop {
|
||||
gba.frame();
|
||||
if let Some(fps) = fps_counter.tick() {
|
||||
println!("FPS: {}", fps);
|
||||
}
|
||||
}
|
||||
}
|
Reference in a new issue