show instruction count together with the mips-count

This commit is contained in:
folkert van heusden 2022-06-16 22:35:15 +02:00
parent c033268ee6
commit a9090e0acd
4 changed files with 8 additions and 6 deletions

View file

@ -66,11 +66,13 @@ uint64_t cpu::get_instructions_executed_count()
return instruction_count;
}
std::pair<double, double> cpu::get_mips_rel_speed()
std::tuple<double, double, uint64_t> 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<double, double> 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()

2
cpu.h
View file

@ -82,7 +82,7 @@ public:
void emulation_start();
uint64_t get_instructions_executed_count();
std::pair<double, double> get_mips_rel_speed();
std::tuple<double, double, uint64_t> get_mips_rel_speed();
void reset();

View file

@ -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) {

View file

@ -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;