diff --git a/cpu.cpp b/cpu.cpp index dd674a0..1e238af 100644 --- a/cpu.cpp +++ b/cpu.cpp @@ -66,11 +66,13 @@ uint64_t cpu::get_instructions_executed_count() return instruction_count; } -std::pair cpu::get_mips_rel_speed() +std::tuple cpu::get_mips_rel_speed() { + uint64_t instr_count = get_instructions_executed_count(); + uint32_t t_diff = get_ms() - running_since; - double mips = get_instructions_executed_count() / (1000.0 * t_diff); + double mips = instr_count / (1000.0 * t_diff); // see https://retrocomputing.stackexchange.com/questions/6960/what-was-the-clock-speed-and-ips-for-the-original-pdp-11 constexpr double pdp11_clock_cycle = 150; // ns, for the 11/70 @@ -78,7 +80,7 @@ std::pair cpu::get_mips_rel_speed() constexpr double pdp11_avg_cycles_per_instruction = (1 + 5) / 2.0; constexpr double pdp11_estimated_mips = pdp11_mhz / pdp11_avg_cycles_per_instruction; - return { mips, mips * 100 / pdp11_estimated_mips }; + return { mips, mips * 100 / pdp11_estimated_mips, instr_count }; } void cpu::reset() diff --git a/cpu.h b/cpu.h index c32a4b8..582c62a 100644 --- a/cpu.h +++ b/cpu.h @@ -82,7 +82,7 @@ public: void emulation_start(); uint64_t get_instructions_executed_count(); - std::pair get_mips_rel_speed(); + std::tuple get_mips_rel_speed(); void reset(); diff --git a/debugger.cpp b/debugger.cpp index 1541a4e..1791b72 100644 --- a/debugger.cpp +++ b/debugger.cpp @@ -290,7 +290,7 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto if (!single_step) { auto speed = c->get_mips_rel_speed(); - cnsl->debug("MIPS: %.2f, relative speed: %.2f%%", speed.first, speed.second); + cnsl->debug("MIPS: %.2f, relative speed: %.2f%%, instructions executed: %lu", std::get<0>(speed), std::get<1>(speed), std::get<2>(speed)); } if (*stop_event == EVENT_INTERRUPT) { diff --git a/main.cpp b/main.cpp index e487ac0..533532e 100644 --- a/main.cpp +++ b/main.cpp @@ -252,7 +252,7 @@ int main(int argc, char *argv[]) auto stats = c->get_mips_rel_speed(); - printf("MIPS: %.2f, running speed: %.2f%%\n", stats.first, stats.second); + printf("MIPS: %.2f, relative speed: %.2f%%, instructions executed: %lu", std::get<0>(stats), std::get<1>(stats), std::get<2>(stats)); } event = EVENT_TERMINATE;