diff options
author | Alexander Lyons Harkness <me@bearbin.net> | 2017-12-23 13:49:08 +0100 |
---|---|---|
committer | Alexander Lyons Harkness <me@bearbin.net> | 2017-12-24 15:23:23 +0100 |
commit | 1926181cb7c8570fe57ec1b39d4241b9dd156333 (patch) | |
tree | 8ac9c6f24285846fa3f97f0a4ade9b0f9996f295 /Tools/MemDumpAnalysis/MemDumpAnalysis.cpp | |
parent | Fixed item ID raw rabbit (#4103) (diff) | |
download | cuberite-1926181cb7c8570fe57ec1b39d4241b9dd156333.tar cuberite-1926181cb7c8570fe57ec1b39d4241b9dd156333.tar.gz cuberite-1926181cb7c8570fe57ec1b39d4241b9dd156333.tar.bz2 cuberite-1926181cb7c8570fe57ec1b39d4241b9dd156333.tar.lz cuberite-1926181cb7c8570fe57ec1b39d4241b9dd156333.tar.xz cuberite-1926181cb7c8570fe57ec1b39d4241b9dd156333.tar.zst cuberite-1926181cb7c8570fe57ec1b39d4241b9dd156333.zip |
Diffstat (limited to '')
-rw-r--r-- | Tools/MemDumpAnalysis/MemDumpAnalysis.cpp | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/Tools/MemDumpAnalysis/MemDumpAnalysis.cpp b/Tools/MemDumpAnalysis/MemDumpAnalysis.cpp index 9faaef20f..58cb304c5 100644 --- a/Tools/MemDumpAnalysis/MemDumpAnalysis.cpp +++ b/Tools/MemDumpAnalysis/MemDumpAnalysis.cpp @@ -25,7 +25,7 @@ public: int m_Size; ///< Sum of memory block sizes allocated by this function or its children int m_Count; ///< Total number of memory blocks allocated by this function or its children AStringSet m_ChildrenNames; - + cFunction(void) : m_Size(0), m_Count(0) @@ -66,7 +66,7 @@ bool IsFnBlackListed(const char * a_FnName) "luaM_realloc_", "", } ; - + for (int i = 0; i < ARRAYCOUNT(BlackList); i++) { if (strcmp(BlackList[i], a_FnName) == 0) @@ -169,7 +169,7 @@ void WriteSizeStatistics(void) { typedef std::vector<std::pair<AString, int> > StringIntPairs; StringIntPairs FnSizes; - + cFile f("memdump_totals.txt", cFile::fmWrite); if (!f.IsOpen()) { @@ -182,7 +182,7 @@ void WriteSizeStatistics(void) FnSizes.push_back(std::pair<AString, int>(itr->first, itr->second.m_Size)); } // for itr - g_FnSizes[] std::sort(FnSizes.begin(), FnSizes.end(), CompareFnInt); - + for (StringIntPairs::const_iterator itr = FnSizes.begin(), end = FnSizes.end(); itr != end; ++itr) { f.Printf("%d\t%s\n", itr->second, itr->first.c_str()); @@ -197,7 +197,7 @@ void WriteCountStatistics(void) { typedef std::vector<std::pair<AString, int> > StringIntPairs; StringIntPairs FnCounts; - + cFile f("memdump_counts.txt", cFile::fmWrite); if (!f.IsOpen()) { @@ -210,7 +210,7 @@ void WriteCountStatistics(void) FnCounts.push_back(std::pair<AString, int>(itr->first, itr->second.m_Count)); } // for itr - g_FnSizes[] std::sort(FnCounts.begin(), FnCounts.end(), CompareFnInt); - + for (StringIntPairs::const_iterator itr = FnCounts.begin(), end = FnCounts.end(); itr != end; ++itr) { f.Printf("%d\t%s\n", itr->second, itr->first.c_str()); @@ -254,7 +254,7 @@ void WriteDotGraph(void) LOGERROR("Cannot open memdump.dot"); return; } - + f.Printf("digraph {\n\tnode [shape=plaintext]\n\n"); for (FunctionMap::const_iterator itrF = g_FnMap.begin(), endF = g_FnMap.end(); itrF != endF; ++itrF) { @@ -288,11 +288,11 @@ int main(int argc, char * argv[]) printf("Cannot open memdump.xml\n"); return 1; } - + // Create the XML parser: XML_Parser Parser = XML_ParserCreate(NULL); XML_SetElementHandler(Parser, OnStartElement, OnEndElement); - + // Feed the file through XML parser: char Buffer[512 KiB]; while (true) @@ -307,15 +307,11 @@ int main(int argc, char * argv[]) } XML_Parse(Parser, "", 0, true); f.Close(); - + // Output the statistics WriteSizeStatistics(); WriteCountStatistics(); WriteDotGraph(); - + return 0; } - - - - |