diff --git a/examples/web/index.ts b/examples/web/index.ts index bc44e84461ef6625c0e1e8136675deca0aaa7c25..60dc960d63602e0c0a062ebeb1d0f7259437374f 100644 --- a/examples/web/index.ts +++ b/examples/web/index.ts @@ -541,19 +541,20 @@ class GameboyEmulator extends Observable implements Emulator { this.boot({ engine: null }); } - benchmark() { + benchmark(count = 50000000) { + let cycles = 0; this.pause(); try { const initial = Date.now(); - const count = 500000000; for (let i = 0; i < count; i++) { - this.gameBoy!.clock(); + cycles += this.gameBoy!.clock(); } const delta = (Date.now() - initial) / 1000; - const frequency_mhz = count / delta / 1000 / 1000; + const frequency_mhz = cycles / delta / 1000 / 1000; return { delta: delta, count: count, + cycles: cycles, frequency_mhz: frequency_mhz }; } finally { diff --git a/examples/web/react/app.tsx b/examples/web/react/app.tsx index e37d64008fe1dd445abddd603422dcaf564644eb..4462d92dbc3f4c0ed4456ca5e99dfe5f5c522a3e 100644 --- a/examples/web/react/app.tsx +++ b/examples/web/react/app.tsx @@ -61,6 +61,7 @@ export type RomInfo = { export type BenchmarkResult = { delta: number; count: number; + cycles: number; frequency_mhz: number; }; @@ -178,9 +179,12 @@ export interface Emulator extends ObservableI { * Runs a benchmark operation in the emulator, effectively * measuring the performance of it. * + * @param count The number of benchmark iterations to be + * run, increasing this value will make the benchmark take + * more time to be executed. * @returns The result metrics from the benchmark run. */ - benchmark(): BenchmarkResult; + benchmark(count?: number): BenchmarkResult; } /** diff --git a/src/cpu.rs b/src/cpu.rs index 8acb6c0c6c010d5ac85c04cef9cd5aa003e0d071..e253dba68cb622d24f5743b7e8646bdd63589b4e 100644 --- a/src/cpu.rs +++ b/src/cpu.rs @@ -124,7 +124,8 @@ impl Cpu { } if self.ime { - // @todo aggregate all of this interrupts in the MMU + // @todo aggregate all of this interrupts in the MMU, as there's + // a lot of redundant code involved in here if (self.mmu.ie & 0x01 == 0x01) && self.mmu.ppu().int_vblank() { debugln!("Going to run V-Blank interrupt handler (0x40)");