From e3d2b625e5cf9cfa820a1ab240ee8b5a34c657d0 Mon Sep 17 00:00:00 2001 From: Jakub Dupak Date: Mon, 23 Dec 2024 16:44:41 +0100 Subject: [PATCH] Core: make cli 2x faster Avoid using time every clock cycle when it is not needed. --- src/machine/machine.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/machine/machine.cpp b/src/machine/machine.cpp index 5ac9ea4c..f5f5f74b 100644 --- a/src/machine/machine.cpp +++ b/src/machine/machine.cpp @@ -5,6 +5,8 @@ #include #include +LOG_CATEGORY("machine"); + using namespace machine; Machine::Machine(MachineConfig config, bool load_symtab, bool load_executable) @@ -361,9 +363,10 @@ void Machine::step_internal(bool skip_break) { set_status(ST_BUSY); emit tick(); try { - QTime start_time = QTime::currentTime(); + // Avoid checking time (expensive) if we don't care about it. + QTime start_time = (time_chunk != 0) ? QTime::currentTime() : QTime(); do { - cr->step(skip_break); + cr->step(skip_break); } while (time_chunk != 0 && stat == ST_BUSY && !skip_break && start_time.msecsTo(QTime::currentTime()) < (int)time_chunk); } catch (SimulatorException &e) {