updated to warn on console when performance is showing poor
This commit is contained in:
parent
d2494605e9
commit
8a7f686e33
|
@ -2045,7 +2045,7 @@ void Game::update() {
|
||||||
|
|
||||||
processNetworkSynchChecksIfRequired();
|
processNetworkSynchChecksIfRequired();
|
||||||
|
|
||||||
gamePerformanceCounts["CalculateNetorkCRCSynchChecks"] = chronoGamePerformanceCounts.getMillis() + gamePerformanceCounts["CalculateNetorkCRCSynchChecks"] / 2;
|
gamePerformanceCounts["CalculateNetworkCRCSynchChecks"] = chronoGamePerformanceCounts.getMillis() + gamePerformanceCounts["CalculateNetworkCRCSynchChecks"] / 2;
|
||||||
chronoGamePerformanceCounts.stop();
|
chronoGamePerformanceCounts.stop();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2802,17 +2802,34 @@ void Game::update() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string Game::getGamePerformanceCounts() const {
|
string Game::getGamePerformanceCounts(bool displayWarnings) const {
|
||||||
if(gamePerformanceCounts.empty() == true) {
|
if(gamePerformanceCounts.empty() == true) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool displayWarningHeader = true;
|
||||||
|
|
||||||
string result = "";
|
string result = "";
|
||||||
for(std::map<string,int64>::const_iterator iterMap = gamePerformanceCounts.begin();
|
for(std::map<string,int64>::const_iterator iterMap = gamePerformanceCounts.begin();
|
||||||
iterMap != gamePerformanceCounts.end(); ++iterMap) {
|
iterMap != gamePerformanceCounts.end(); ++iterMap) {
|
||||||
if(result != "") {
|
if(result != "") {
|
||||||
result += "\n";
|
result += "\n";
|
||||||
}
|
}
|
||||||
result += iterMap->first + " = avg millis: " + intToStr(iterMap->second);
|
string perfStat = iterMap->first + " = avg millis: " + intToStr(iterMap->second);
|
||||||
|
|
||||||
|
if(displayWarnings == true) {
|
||||||
|
int WARNING_MILLIS = Config::getInstance().getInt("PerformanceWarningMillis","10");
|
||||||
|
if(iterMap->second >= WARNING_MILLIS) {
|
||||||
|
if(displayWarningHeader == true) {
|
||||||
|
displayWarningHeader = false;
|
||||||
|
printf("=====================================\nPERFORMANCE WARNINGS for World Frame: %d\n",world.getFrameCount());
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("*PERFORMANCE WARNING* %s\n",perfStat.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result += perfStat;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -5478,6 +5495,14 @@ void Game::render2d() {
|
||||||
if(this->getRenderInGamePerformance() == true) {
|
if(this->getRenderInGamePerformance() == true) {
|
||||||
renderer.renderPerformanceStats();
|
renderer.renderPerformanceStats();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
static time_t lastGamePerfCheck = time(NULL);
|
||||||
|
if(difftime((long int)time(NULL),lastGamePerfCheck) > 3) {
|
||||||
|
lastGamePerfCheck = time(NULL);
|
||||||
|
|
||||||
|
getGamePerformanceCounts(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(renderer.getShowDebugUI() == true) {
|
if(renderer.getShowDebugUI() == true) {
|
||||||
const Metrics &metrics= Metrics::getInstance();
|
const Metrics &metrics= Metrics::getInstance();
|
||||||
|
|
|
@ -339,7 +339,7 @@ public:
|
||||||
bool getDisableSpeedChange() const { return disableSpeedChange; }
|
bool getDisableSpeedChange() const { return disableSpeedChange; }
|
||||||
void setDisableSpeedChange(bool value) { disableSpeedChange = value; }
|
void setDisableSpeedChange(bool value) { disableSpeedChange = value; }
|
||||||
|
|
||||||
string getGamePerformanceCounts() const;
|
string getGamePerformanceCounts(bool displayWarnings) const;
|
||||||
bool getRenderInGamePerformance() const { return renderInGamePerformance; }
|
bool getRenderInGamePerformance() const { return renderInGamePerformance; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -2235,7 +2235,7 @@ void Renderer::renderPerformanceStats() {
|
||||||
static string gamePerfStats = "";
|
static string gamePerfStats = "";
|
||||||
if(difftime((long int)time(NULL),lastGamePerfCheck) > 3) {
|
if(difftime((long int)time(NULL),lastGamePerfCheck) > 3) {
|
||||||
lastGamePerfCheck = time(NULL);
|
lastGamePerfCheck = time(NULL);
|
||||||
gamePerfStats = game->getGamePerformanceCounts();
|
gamePerfStats = game->getGamePerformanceCounts(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(gamePerfStats != "") {
|
if(gamePerfStats != "") {
|
||||||
|
|
Loading…
Reference in New Issue