diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-04-26 22:45:55 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-04-26 22:45:55 +0300 |
commit | 80bbbc4c18273e0d1116d7e924d1df068a5d63d5 (patch) | |
tree | bef2f6458ee7fc5079c1993921abdfc4926570bb /src | |
parent | 918e2a5cf24311e87b0dc754770480727f77eac3 (diff) | |
download | plus-80bbbc4c18273e0d1116d7e924d1df068a5d63d5.tar.gz plus-80bbbc4c18273e0d1116d7e924d1df068a5d63d5.tar.bz2 plus-80bbbc4c18273e0d1116d7e924d1df068a5d63d5.tar.xz plus-80bbbc4c18273e0d1116d7e924d1df068a5d63d5.zip |
Add chat command for print memory usage. For now only report about resources.
New chat command: /dumpmemoryusage
Diffstat (limited to 'src')
-rw-r--r-- | src/actions/actions.cpp | 7 | ||||
-rw-r--r-- | src/actions/actions.h | 1 | ||||
-rw-r--r-- | src/dyetool/actions/actions.cpp | 1 | ||||
-rw-r--r-- | src/enums/input/inputaction.h | 1 | ||||
-rw-r--r-- | src/input/inputactionmap.h | 6 | ||||
-rw-r--r-- | src/resources/memorymanager.cpp | 19 | ||||
-rw-r--r-- | src/resources/memorymanager.h | 2 |
7 files changed, 37 insertions, 0 deletions
diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp index 1f7df9c9d..1e7a9ad5b 100644 --- a/src/actions/actions.cpp +++ b/src/actions/actions.cpp @@ -96,6 +96,7 @@ #include "net/tradehandler.h" #include "resources/iteminfo.h" +#include "resources/memorymanager.h" #include "resources/resourcemanager.h" #include "const/resources/skill.h" @@ -1783,4 +1784,10 @@ impHandler(seen) return true; } +impHandler0(dumpMemoryUsage) +{ + memoryManager.printAllMemory(); + return true; +} + } // namespace Actions diff --git a/src/actions/actions.h b/src/actions/actions.h index 7d583527b..a09022ce7 100644 --- a/src/actions/actions.h +++ b/src/actions/actions.h @@ -113,6 +113,7 @@ namespace Actions decHandler(resetGameModifiers); decHandler(barToChat); decHandler(seen); + decHandler(dumpMemoryUsage); } // namespace Actions #undef decHandler diff --git a/src/dyetool/actions/actions.cpp b/src/dyetool/actions/actions.cpp index bcb5bb98d..e226464a6 100644 --- a/src/dyetool/actions/actions.cpp +++ b/src/dyetool/actions/actions.cpp @@ -110,5 +110,6 @@ impHandlerVoid(craftKey) impHandlerVoid(resetGameModifiers) impHandlerVoid(barToChat) impHandlerVoid(seen) +impHandlerVoid(dumpMemoryUsage) } // namespace Actions diff --git a/src/enums/input/inputaction.h b/src/enums/input/inputaction.h index 1996602da..f0da06745 100644 --- a/src/enums/input/inputaction.h +++ b/src/enums/input/inputaction.h @@ -669,6 +669,7 @@ enumStart(InputAction) COMMAND_GUILD_RECALL, MAIL_TO, ADOPT_CHILD, + DUMP_MEMORY_USAGE, TOTAL } enumEnd(InputAction); diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h index 2a12b5765..6d3c957e3 100644 --- a/src/input/inputactionmap.h +++ b/src/input/inputactionmap.h @@ -5503,6 +5503,12 @@ static const InputActionData inputActionData "adoptchild|childadopt|askforchild", UseArgs_true, Protected_true}, + {"keyDumpMemmoryUsage", + defaultAction(&Actions::dumpMemoryUsage), + InputCondition::INGAME, + "dumpmemoryusage|memoryusage", + UseArgs_false, + Protected_true}, }; #undef defaultAction diff --git a/src/resources/memorymanager.cpp b/src/resources/memorymanager.cpp index a07aaa750..a88d53b79 100644 --- a/src/resources/memorymanager.cpp +++ b/src/resources/memorymanager.cpp @@ -20,7 +20,12 @@ #include "resources/memorymanager.h" +#include "logger.h" + +#include "resources/resourcemanager.h" + #include <SDL_video.h> +#include <string> #include "debug.h" @@ -49,4 +54,18 @@ void MemoryManager::printMemory(const int level A_UNUSED, const int localSum A_UNUSED, const int childsSum A_UNUSED) { + std::string str(level, ' '); + logger->log("%s%d = %d + %d", + str.c_str(), + localSum + childsSum, + localSum, + childsSum); +} + +void MemoryManager::printAllMemory() +{ + if (!logger) + return; + if (resourceManager) + resourceManager->calcMemory(0); } diff --git a/src/resources/memorymanager.h b/src/resources/memorymanager.h index 88b55e617..658876776 100644 --- a/src/resources/memorymanager.h +++ b/src/resources/memorymanager.h @@ -40,6 +40,8 @@ class MemoryManager final void printMemory(const int level, const int localSum, const int childsSum); + + void printAllMemory(); }; extern MemoryManager memoryManager; |