diff options
author | Andrei Karas <akaras@inbox.ru> | 2018-09-07 20:58:59 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2018-09-07 20:58:59 +0300 |
commit | 32b9e2070b3cf44b6b38ab0c0383b85e87852d50 (patch) | |
tree | 352d7a4c3dcb8fbffadeb127cee0090aa98d073a /src/progs | |
parent | abfc18794cbd9119c110f32e39ea48a00e5b9214 (diff) | |
download | manaplus-32b9e2070b3cf44b6b38ab0c0383b85e87852d50.tar.gz manaplus-32b9e2070b3cf44b6b38ab0c0383b85e87852d50.tar.bz2 manaplus-32b9e2070b3cf44b6b38ab0c0383b85e87852d50.tar.xz manaplus-32b9e2070b3cf44b6b38ab0c0383b85e87852d50.zip |
Add basic performance counters.
Add in debug window new tab with this counters.
Diffstat (limited to 'src/progs')
-rw-r--r-- | src/progs/manaplus/client.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/progs/manaplus/client.cpp b/src/progs/manaplus/client.cpp index 880f05a0b..01348db2d 100644 --- a/src/progs/manaplus/client.cpp +++ b/src/progs/manaplus/client.cpp @@ -127,6 +127,7 @@ #ifdef ANDROID #include "fs/paths.h" #endif // ANDROID +#include "utils/perfstat.h" #include "utils/sdlcheckutils.h" #include "utils/sdlhelper.h" #include "utils/timer.h" @@ -952,20 +953,30 @@ int Client::gameExec() { int lastTickTime = tick_time; + Perf::init(); + while (mState != State::EXIT) { PROFILER_START(); + PERF_STAT(0); if (eventsManager.handleEvents()) continue; + PERF_STAT(1); + BLOCK_START("Client::gameExec 3") if (generalHandler != nullptr) generalHandler->flushNetwork(); BLOCK_END("Client::gameExec 3") + PERF_STAT(2); + BLOCK_START("Client::gameExec 4") if (gui != nullptr) gui->logic(); + + PERF_STAT(3); + cur_time = time(nullptr); int k = 0; while (lastTickTime != tick_time && @@ -979,14 +990,28 @@ int Client::gameExec() ++lastTickTime; k ++; } + + PERF_STAT(4); + soundManager.logic(); + PERF_STAT(5); + logic_count += k; if (gui != nullptr) gui->slowLogic(); + + PERF_STAT(6); + if (mGame != nullptr) mGame->slowLogic(); + + PERF_STAT(7); + slowLogic(); + + PERF_STAT(8); + BLOCK_END("Client::gameExec 4") // This is done because at some point tick_time will wrap. @@ -1005,11 +1030,15 @@ int Client::gameExec() SDL_Delay(100); } + PERF_STAT(9); + BLOCK_START("~Client::SDL_framerateDelay") if (settings.limitFps) SDL_framerateDelay(&fpsManager); BLOCK_END("~Client::SDL_framerateDelay") + PERF_STAT(10); + BLOCK_START("Client::gameExec 6") if (mState == State::CONNECT_GAME) { @@ -1034,6 +1063,8 @@ int Client::gameExec() } BLOCK_END("Client::gameExec 6") + PERF_STAT(11); + if (mState != mOldState) { BLOCK_START("Client::gameExec 7") @@ -1373,6 +1404,7 @@ int Client::gameExec() if (mumbleManager) mumbleManager->setPlayer(localPlayer->getName()); #endif // USE_MUMBLE + Perf::init(); } // Fade out logon-music here too to give the desired effect @@ -1656,6 +1688,8 @@ int Client::gameExec() } BLOCK_END("Client::gameExec 8") } + PERF_STAT(12); + PERF_NEXTFRAME(); PROFILER_END(); } |