1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-08 22:26:51 +02:00

Add time measurement for auto-battle

This commit is contained in:
MichalZr6
2024-09-15 11:22:37 +02:00
parent 8406840f76
commit f792eb2da5

View File

@@ -814,11 +814,21 @@ void ApplyClientNetPackVisitor::visitBattleNextRound(BattleNextRound & pack)
callBattleInterfaceIfPresentForBothSides(cl, pack.battleID, &IBattleEventsReceiver::battleNewRound, pack.battleID);
}
uint64_t timeElapsed(std::chrono::time_point<std::chrono::high_resolution_clock> start)
{
auto end = std::chrono::high_resolution_clock::now();
return std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
}
void ApplyClientNetPackVisitor::visitBattleSetActiveStack(BattleSetActiveStack & pack)
{
if(!pack.askPlayerInterface)
return;
auto start = std::chrono::steady_clock::now();
static uint64_t duration = 0;
const CStack *activated = gs.getBattle(pack.battleID)->battleGetStackByID(pack.stack);
PlayerColor playerToCall; //pack.player that will move activated stack
if(activated->isHypnotized())
@@ -833,6 +843,8 @@ void ApplyClientNetPackVisitor::visitBattleSetActiveStack(BattleSetActiveStack &
}
cl.startPlayerBattleAction(pack.battleID, playerToCall);
duration += timeElapsed(start);
logGlobal->warn("Battle elapsed for %ld ms", duration);
}
void ApplyClientNetPackVisitor::visitBattleLogMessage(BattleLogMessage & pack)