From a9090e0acd00983aa4fb320fb1e183de71d8ddf5 Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Thu, 16 Jun 2022 22:35:15 +0200 Subject: [PATCH] show instruction count together with the mips-count --- cpu.cpp | 8 +++++--- cpu.h | 2 +- debugger.cpp | 2 +- main.cpp | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) 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;