Run clang-format

This commit is contained in:
Yunfan Li
2024-08-04 10:23:36 +08:00
parent 44da167492
commit 53611c9040
835 changed files with 35085 additions and 31861 deletions

View File

@@ -1,11 +1,14 @@
/*
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version.
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license, you may redistribute it
* and/or modify it under version 2 of the License, or (at your option), any later version.
*/
#include "PerformanceMonitor.h"
#include "Playerbots.h"
PerformanceMonitorOperation* PerformanceMonitor::start(PerformanceMetric metric, std::string const name, PerformanceStack* stack)
PerformanceMonitorOperation* PerformanceMonitor::start(PerformanceMetric metric, std::string const name,
PerformanceStack* stack)
{
if (!sPlayerbotAIConfig->perfMonEnabled)
return nullptr;
@@ -50,7 +53,6 @@ void PerformanceMonitor::PrintStats(bool perTick, bool fullStack)
if (data.empty())
return;
if (!perTick)
{
float updateAITotalTime = 0;
@@ -58,11 +60,17 @@ void PerformanceMonitor::PrintStats(bool perTick, bool fullStack)
if (map.first.find("PlayerbotAI::UpdateAIInternal") != std::string::npos)
updateAITotalTime += map.second->totalTime;
LOG_INFO("playerbots", "--------------------------------------[TOTAL BOT]------------------------------------------------------");
LOG_INFO("playerbots", "percentage time | min .. max ( avg of count) - type : name");
LOG_INFO("playerbots", "-------------------------------------------------------------------------------------------------------");
LOG_INFO(
"playerbots",
"--------------------------------------[TOTAL BOT]------------------------------------------------------");
LOG_INFO("playerbots",
"percentage time | min .. max ( avg of count) - type : name");
LOG_INFO(
"playerbots",
"-------------------------------------------------------------------------------------------------------");
for (std::map<PerformanceMetric, std::map<std::string, PerformanceData*>>::iterator i = data.begin(); i != data.end(); ++i)
for (std::map<PerformanceMetric, std::map<std::string, PerformanceData*>>::iterator i = data.begin();
i != data.end(); ++i)
{
std::map<std::string, PerformanceData*> pdMap = i->second;
@@ -99,10 +107,9 @@ void PerformanceMonitor::PrintStats(bool perTick, bool fullStack)
names.push_back(j->first);
}
std::sort(names.begin(), names.end(), [pdMap](std::string const i, std::string const j)
{
return pdMap.at(i)->totalTime < pdMap.at(j)->totalTime;
});
std::sort(names.begin(), names.end(),
[pdMap](std::string const i, std::string const j)
{ return pdMap.at(i)->totalTime < pdMap.at(j)->totalTime; });
uint64 typeTotalTime = 0;
uint64 typeMinTime = 0xffffffffu;
@@ -128,15 +135,9 @@ void PerformanceMonitor::PrintStats(bool perTick, bool fullStack)
if (perc >= 0.1f || avg >= 0.25f || pd->maxTime > 1000)
{
LOG_INFO("playerbots", "{:7.3f}% {:10.3f}s | {:7.1f} .. {:7.1f} ({:10.3f} of {:10d}) - {:6} : {}"
, perc
, time
, minTime
, maxTime
, avg
, pd->count
, key.c_str()
, disName.c_str());
LOG_INFO("playerbots",
"{:7.3f}% {:10.3f}s | {:7.1f} .. {:7.1f} ({:10.3f} of {:10d}) - {:6} : {}", perc, time,
minTime, maxTime, avg, pd->count, key.c_str(), disName.c_str());
}
}
float tPerc = (float)typeTotalTime / (float)updateAITotalTime * 100.0f;
@@ -144,15 +145,8 @@ void PerformanceMonitor::PrintStats(bool perTick, bool fullStack)
float tMinTime = (float)typeMinTime / 1000.0f;
float tMaxTime = (float)typeMaxTime / 1000.0f;
float tAvg = (float)typeTotalTime / (float)typeCount / 1000.0f;
LOG_INFO("playerbots", "{:7.3f}% {:10.3f}s | {:7.1f} .. {:7.1f} ({:10.3f} of {:10d}) - {:6} : {}"
, tPerc
, tTime
, tMinTime
, tMaxTime
, tAvg
, typeCount
, key.c_str()
, "Total");
LOG_INFO("playerbots", "{:7.3f}% {:10.3f}s | {:7.1f} .. {:7.1f} ({:10.3f} of {:10d}) - {:6} : {}", tPerc,
tTime, tMinTime, tMaxTime, tAvg, typeCount, key.c_str(), "Total");
LOG_INFO("playerbots", " ");
}
}
@@ -161,11 +155,17 @@ void PerformanceMonitor::PrintStats(bool perTick, bool fullStack)
float fullTickCount = data[PERF_MON_TOTAL]["RandomPlayerbotMgr::FullTick"]->count;
float fullTickTotalTime = data[PERF_MON_TOTAL]["RandomPlayerbotMgr::FullTick"]->totalTime;
LOG_INFO("playerbots", "---------------------------------------[PER TICK]------------------------------------------------------");
LOG_INFO("playerbots", "percentage time | min .. max ( avg of count) - type : name");
LOG_INFO("playerbots", "-------------------------------------------------------------------------------------------------------");
LOG_INFO(
"playerbots",
"---------------------------------------[PER TICK]------------------------------------------------------");
LOG_INFO("playerbots",
"percentage time | min .. max ( avg of count) - type : name");
LOG_INFO(
"playerbots",
"-------------------------------------------------------------------------------------------------------");
for (std::map<PerformanceMetric, std::map<std::string, PerformanceData*>>::iterator i = data.begin(); i != data.end(); ++i)
for (std::map<PerformanceMetric, std::map<std::string, PerformanceData*>>::iterator i = data.begin();
i != data.end(); ++i)
{
std::map<std::string, PerformanceData*> pdMap = i->second;
@@ -198,10 +198,9 @@ void PerformanceMonitor::PrintStats(bool perTick, bool fullStack)
names.push_back(j->first);
}
std::sort(names.begin(), names.end(), [pdMap](std::string const i, std::string const j)
{
return pdMap.at(i)->totalTime < pdMap.at(j)->totalTime;
});
std::sort(names.begin(), names.end(),
[pdMap](std::string const i, std::string const j)
{ return pdMap.at(i)->totalTime < pdMap.at(j)->totalTime; });
uint64 typeTotalTime = 0;
uint64 typeMinTime = 0xffffffffu;
@@ -227,15 +226,9 @@ void PerformanceMonitor::PrintStats(bool perTick, bool fullStack)
disName = disName.substr(0, disName.find("|")) + "]";
if (perc >= 0.1f || avg >= 0.25f || pd->maxTime > 1000)
{
LOG_INFO("playerbots", "{:7.3f}% {:9.3f}ms | {:7.1f} .. {:7.1f} ({:10.3f} of {:10.2f}) - {:6} : {}"
, perc
, time
, minTime
, maxTime
, avg
, amount
, key.c_str()
, disName.c_str());
LOG_INFO("playerbots",
"{:7.3f}% {:9.3f}ms | {:7.1f} .. {:7.1f} ({:10.3f} of {:10.2f}) - {:6} : {}", perc,
time, minTime, maxTime, avg, amount, key.c_str(), disName.c_str());
}
}
if (PERF_MON_TOTAL != i->first)
@@ -246,15 +239,8 @@ void PerformanceMonitor::PrintStats(bool perTick, bool fullStack)
float tMaxTime = (float)typeMaxTime / 1000.0f;
float tAvg = (float)typeTotalTime / (float)typeCount / 1000.0f;
float tAmount = (float)typeCount / fullTickCount;
LOG_INFO("playerbots", "{:7.3f}% {:9.3f}ms | {:7.1f} .. {:7.1f} ({:10.3f} of {:10.2f}) - {:6} : {}"
, tPerc
, tTime
, tMinTime
, tMaxTime
, tAvg
, tAmount
, key.c_str()
, "Total");
LOG_INFO("playerbots", "{:7.3f}% {:9.3f}ms | {:7.1f} .. {:7.1f} ({:10.3f} of {:10.2f}) - {:6} : {}",
tPerc, tTime, tMinTime, tMaxTime, tAvg, tAmount, key.c_str(), "Total");
}
LOG_INFO("playerbots", " ");
}
@@ -263,7 +249,8 @@ void PerformanceMonitor::PrintStats(bool perTick, bool fullStack)
void PerformanceMonitor::Reset()
{
for (std::map<PerformanceMetric, std::map<std::string, PerformanceData*> >::iterator i = data.begin(); i != data.end(); ++i)
for (std::map<PerformanceMetric, std::map<std::string, PerformanceData*>>::iterator i = data.begin();
i != data.end(); ++i)
{
std::map<std::string, PerformanceData*> pdMap = i->second;
for (std::map<std::string, PerformanceData*>::iterator j = pdMap.begin(); j != pdMap.end(); ++j)
@@ -278,14 +265,19 @@ void PerformanceMonitor::Reset()
}
}
PerformanceMonitorOperation::PerformanceMonitorOperation(PerformanceData* data, std::string const name, PerformanceStack* stack) : data(data), name(name), stack(stack)
PerformanceMonitorOperation::PerformanceMonitorOperation(PerformanceData* data, std::string const name,
PerformanceStack* stack)
: data(data), name(name), stack(stack)
{
started = (std::chrono::time_point_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now())).time_since_epoch();
started = (std::chrono::time_point_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now()))
.time_since_epoch();
}
void PerformanceMonitorOperation::finish()
{
std::chrono::microseconds finished = (std::chrono::time_point_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now())).time_since_epoch();
std::chrono::microseconds finished =
(std::chrono::time_point_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now()))
.time_since_epoch();
uint64_t elapsed = (finished - started).count();
std::lock_guard<std::mutex> guard(data->lock);
@@ -309,4 +301,3 @@ void PerformanceMonitorOperation::finish()
delete this;
}