From e920ee230eab16e1bde31067574c7145e7361082 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Sun, 12 May 2013 22:14:49 -0400 Subject: [PATCH] change debugging to test speed --- bin/loader.cpp | 22 +++++++++++++++++++++- cpu/CpuModule.h | 2 +- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/bin/loader.cpp b/bin/loader.cpp index c39e8fe..f27dead 100644 --- a/bin/loader.cpp +++ b/bin/loader.cpp @@ -4,6 +4,8 @@ #include #include #include +#include + #include #include #include @@ -761,6 +763,8 @@ int main(int argc, char **argv) { NULL, 0, NULL, 0 } }; + //auto start_time = std::chrono::high_resolution_clock::now(); + int c; while ((c = getopt_long(argc, argv, "+hVm:r:s:", LongOpts, NULL)) != -1) { @@ -921,13 +925,21 @@ int main(int argc, char **argv) if (Flags.traceCPU || Flags.traceMacsbug) { + #ifdef CPU_INSTRUCTION_LOGGING cpuSetInstructionLoggingFunc(InstructionLogger); + #endif + // else do it manually below. } cpuInitializeFromNewPC(address); + #if 0 + auto begin_emu_time = std::chrono::high_resolution_clock::now(); + fprintf(stderr, "Begin Emulation Time: %20lld\n", (begin_emu_time - start_time).count()); + #endif + uint64_t cycles = 0; for (;;) { uint32_t pc = cpuGetPC(); @@ -954,9 +966,15 @@ int main(int argc, char **argv) if (cpuGetStop()) break; // will this also be set by an interrupt? - cpuExecuteInstruction(); + cycles += cpuExecuteInstruction(); } + #if 0 + auto end_emu_time = std::chrono::high_resolution_clock::now(); + fprintf(stderr, " End Emulation Time: %20lld\n", (end_emu_time - start_time).count()); + fprintf(stderr, " Cycles: %20lld\n", cycles); + #endif + if (Flags.memoryStats) { MM::Native::PrintMemoryStats(); @@ -965,5 +983,7 @@ int main(int argc, char **argv) uint32_t rv = MPW::ExitStatus(); if (rv > 0xff) rv = 0xff; + + exit(rv); } \ No newline at end of file diff --git a/cpu/CpuModule.h b/cpu/CpuModule.h index dcd92e6..7e932d6 100644 --- a/cpu/CpuModule.h +++ b/cpu/CpuModule.h @@ -12,7 +12,7 @@ extern void cpuSetFLineExceptionFunc(cpuLineExceptionFunc func); // This header file defines the internal interfaces of the CPU module. -#define CPU_INSTRUCTION_LOGGING +//#define CPU_INSTRUCTION_LOGGING // Function to check if there are any external interrupt sources wanting to issue interrupts typedef BOOLE (*cpuCheckPendingInterruptsFunc)(void);