Skip to content
Snippets Groups Projects
Verified Commit cdcfc326 authored by João Magalhães's avatar João Magalhães :rocket:
Browse files

chore: support for benchmark

In the SDL version.
parent f7f5e8ee
No related branches found
No related tags found
No related merge requests found
Pipeline #2825 passed
......@@ -127,3 +127,5 @@ jobs:
run: cd frontends/sdl && cargo build --release
- name: Run release version
run: cd frontends/sdl && cargo run --release -- --headless --cycles 10000000
- name: Run benchmark
run: cd frontends/sdl && cargo run --release -- --benchmark
......@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
* Support for the `clock_m()` function
* Benchmark CLI option in SDL
### Changed
......
......@@ -226,22 +226,22 @@ impl Emulator {
let count = params.count;
let chunk_size = params.chunk_size.unwrap_or(1);
let mut cycles = 0;
let mut cycles = 0u64;
let initial = SystemTime::now();
if chunk_size > 1 {
for _ in 0..(count / chunk_size) {
cycles += self.system.clock_m(chunk_size) as u32;
cycles += self.system.clock_m(chunk_size) as u64;
}
} else {
for _ in 0..count {
cycles += self.system.clock() as u32;
cycles += self.system.clock() as u64;
}
}
let delta = initial.elapsed().unwrap().as_millis() as f32 / 1000.0;
let frequency_mhz = cycles as f32 / delta / 1000.0 / 1000.0;
let delta = initial.elapsed().unwrap().as_millis() as f64 / 1000.0;
let frequency_mhz = cycles as f64 / delta / 1000.0 / 1000.0;
println!(
"Took {:.2} seconds to run {} ticks ({} cycles) ({:.2} Mhz)!",
......@@ -607,6 +607,13 @@ struct Args {
#[arg(long, default_value_t = false, help = "If set no timer will be used")]
no_timer: bool,
#[arg(
long,
default_value_t = false,
help = "Run in benchmark mode, with no UI"
)]
benchmark: bool,
#[arg(
long,
default_value_t = false,
......@@ -663,7 +670,7 @@ fn main() {
let options = EmulatorOptions {
auto_mode: Some(auto_mode),
unlimited: Some(args.unlimited),
features: if args.headless {
features: if args.headless || args.benchmark {
Some(vec![])
} else {
Some(vec!["video", "audio", "no-vsync"])
......@@ -677,7 +684,9 @@ fn main() {
// determines if the emulator should run in headless mode or
// not and runs it accordingly, note that if running in headless
// mode the number of cycles to be run may be specified
if args.headless {
if args.benchmark {
emulator.benchmark(Benchmark::new(500000000, None));
} else if args.headless {
emulator.run_headless(if args.cycles > 0 {
Some(args.cycles)
} else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment