updated to warn on console when performance is showing poor

This commit is contained in:
Mark Vejvoda 2013-11-11 04:08:10 +00:00
parent d2494605e9
commit 8a7f686e33
3 changed files with 30 additions and 5 deletions

View File

@ -2045,7 +2045,7 @@ void Game::update() {
processNetworkSynchChecksIfRequired();
gamePerformanceCounts["CalculateNetorkCRCSynchChecks"] = chronoGamePerformanceCounts.getMillis() + gamePerformanceCounts["CalculateNetorkCRCSynchChecks"] / 2;
gamePerformanceCounts["CalculateNetworkCRCSynchChecks"] = chronoGamePerformanceCounts.getMillis() + gamePerformanceCounts["CalculateNetworkCRCSynchChecks"] / 2;
chronoGamePerformanceCounts.stop();
/*
@ -2802,17 +2802,34 @@ void Game::update() {
}
}
string Game::getGamePerformanceCounts() const {
string Game::getGamePerformanceCounts(bool displayWarnings) const {
if(gamePerformanceCounts.empty() == true) {
return "";
}
bool displayWarningHeader = true;
string result = "";
for(std::map<string,int64>::const_iterator iterMap = gamePerformanceCounts.begin();
iterMap != gamePerformanceCounts.end(); ++iterMap) {
if(result != "") {
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;
@ -5478,6 +5495,14 @@ void Game::render2d() {
if(this->getRenderInGamePerformance() == true) {
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) {
const Metrics &metrics= Metrics::getInstance();

View File

@ -339,7 +339,7 @@ public:
bool getDisableSpeedChange() const { return disableSpeedChange; }
void setDisableSpeedChange(bool value) { disableSpeedChange = value; }
string getGamePerformanceCounts() const;
string getGamePerformanceCounts(bool displayWarnings) const;
bool getRenderInGamePerformance() const { return renderInGamePerformance; }
private:

View File

@ -2235,7 +2235,7 @@ void Renderer::renderPerformanceStats() {
static string gamePerfStats = "";
if(difftime((long int)time(NULL),lastGamePerfCheck) > 3) {
lastGamePerfCheck = time(NULL);
gamePerfStats = game->getGamePerformanceCounts();
gamePerfStats = game->getGamePerformanceCounts(true);
}
if(gamePerfStats != "") {