Checkpoint on a utility helper class. Basically, if you have a class that you want to count the numbers of instances, you do this:

class Foo
#ifdef TRACK_OBJECT_USAGE
      : public InstanceCounter<Foo>
#endif

Then, use this macro somewhere in the class body:
SUPPORT_OBJECT_ANALYTICS(Foo)

Lastly, add whatever information you want to trace out to the function ObjectAnalytics::DumpStatistics().

Here's a sample of the output of what I've instrumented so far:

-----------------------------------------------------------
Object Usage Stats

CardPrimitive current count: 7899
CardPrimitive current byte usage: 2053740
CardPrimitive max count: 7908
CardPrimitive max byte usage: 2056080

MTGCard current count: 13973
MTGCard current byte usage: 670704
MTGCard max count: 13982
MTGCard max byte usage: 671136

MTGCardInstance current count: 180
MTGCardInstance current byte usage: 172080
MTGCardInstance max count: 189
MTGCardInstance max byte usage: 180684

-----------------------------------------------------------
This commit is contained in:
wrenczes@gmail.com
2011-04-23 05:16:53 +00:00
parent 8e4de36588
commit bd56723bc0
13 changed files with 167 additions and 1 deletions

View File

@@ -379,6 +379,7 @@
<ClCompile Include="src\MTGPack.cpp" />
<ClCompile Include="src\MTGRules.cpp" />
<ClCompile Include="src\Navigator.cpp" />
<ClCompile Include="src\ObjectAnalytics.cpp" />
<ClCompile Include="src\OptionItem.cpp" />
<ClCompile Include="src\PhaseRing.cpp" />
<ClCompile Include="src\Player.cpp" />
@@ -492,6 +493,7 @@
<ClInclude Include="include\MTGPack.h" />
<ClInclude Include="include\MTGRules.h" />
<ClInclude Include="include\Navigator.h" />
<ClInclude Include="include\ObjectAnalytics.h" />
<ClInclude Include="include\OptionItem.h" />
<ClInclude Include="include\OSD.h" />
<ClInclude Include="include\PhaseRing.h" />