Skip to content

Commit

Permalink
Core: make cli 2x faster
Browse files Browse the repository at this point in the history
Avoid using time every clock cycle when it is not needed.
  • Loading branch information
jdupak committed Dec 23, 2024
1 parent 928557e commit e3d2b62
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/machine/machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <QTime>
#include <utility>

LOG_CATEGORY("machine");

using namespace machine;

Machine::Machine(MachineConfig config, bool load_symtab, bool load_executable)
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit e3d2b62

Please sign in to comment.