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:
@@ -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)
|
||||
|
Reference in New Issue
Block a user