diff --git a/cpu.cpp b/cpu.cpp index 66ad8fe..8513971 100644 --- a/cpu.cpp +++ b/cpu.cpp @@ -78,7 +78,7 @@ std::tuple cpu::get_mips_rel_speed(c uint64_t t_diff = t_diff_in.has_value() ? t_diff_in.value() : (get_us() - running_since - wait_time); - double mips = instr_count / double(t_diff); + double mips = t_diff ? instr_count / double(t_diff) : 0; // 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 diff --git a/debugger.cpp b/debugger.cpp index dd42648..fc68676 100644 --- a/debugger.cpp +++ b/debugger.cpp @@ -211,7 +211,7 @@ void reg_dump(console *const cnsl, cpu *const c) void show_run_statistics(console *const cnsl, cpu *const c) { - auto stats = c->get_mips_rel_speed({ }, false); + auto stats = c->get_mips_rel_speed({ }, { }); cnsl->put_string_lf(format("Executed %zu instructions in %.2f ms of which %.2f ms idle", size_t(std::get<2>(stats)), std::get<3>(stats) / 1000., std::get<4>(stats) / 1000.)); cnsl->put_string_lf(format("MIPS: %.2f, relative speed: %.2f%%", std::get<0>(stats), std::get<1>(stats))); diff --git a/main.cpp b/main.cpp index 6bb27f1..2105127 100644 --- a/main.cpp +++ b/main.cpp @@ -551,7 +551,7 @@ int main(int argc, char *argv[]) break; } - auto stats = c->get_mips_rel_speed({ }, false); + auto stats = c->get_mips_rel_speed({ }, { }); cnsl->put_string_lf(format("MIPS: %.2f, relative speed: %.2f%%, instructions executed: %" PRIu64 " in %.2f seconds", std::get<0>(stats), std::get<1>(stats), std::get<2>(stats), std::get<3>(stats) / 1000000.)); }