gwnavruntime/database/querystatistics.h Source File

querystatistics.h
Go to the documentation of this file.
1 /*
2 * Copyright 2016 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 #pragma once
8 
12 
13 namespace Kaim
14 {
15 
16 class Database;
17 class StringBuffer;
18 
19 class PerformQueryStatCounter
20 {
21  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_WorldFwk)
22 public:
23  void Clear()
24  {
25  for (KyUInt32 i = 0; i < QueryType_FirstCustom; ++i)
26  m_perQueryCounter[i] = 0;
27  }
28 
29  void Increment(QueryType queryType) { ++m_perQueryCounter[queryType]; }
30 
31  KyUInt32 GetCount(QueryType queryType) const { return m_perQueryCounter[queryType]; }
32 
33 public:
34  KyUInt32 m_perQueryCounter[QueryType_FirstCustom];
35 };
36 
38 {
39  QueryStatReport_RelevantOnly,
41 };
42 
43 #if defined(KY_CONFIG_DEBUG_OR_DEV)
44 
58 class PerformQueryStatistics
59 {
60  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_WorldFwk)
61 public:
62 
64  void ResetPerformQueryCounter();
65 
67  void Report(StringBuffer* report, QueryStatReportType reportType = QueryStatReport_RelevantOnly) const;
68 
69 public: // internal
70  void Initialize();
71 
72  static const char* GetPerformQueryStatName(PerformQueryStat queryStat);
73 
74  void IncrementPerformQueryStat(PerformQueryStat stat, QueryType queryType) { if (stat < PerformQueryStat_Count) m_queryStatCounter[stat].Increment(queryType); }
75 
76  KyUInt32 GetPerformQueryStatCount(PerformQueryStat stat, QueryType queryType) { return m_queryStatCounter[stat].GetCount(queryType); }
77 
78  KyUInt32& GetPerformQueryCount(QueryType queryType) { return m_perQueryCounter[queryType]; }
79 
80 public:
81  KyArray<KyUInt32> m_perQueryCounter;
82  KyArray<PerformQueryStatCounter> m_queryStatCounter;
83 };
84 
86 class ScopedPerformedQueryCounter
87 {
88  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_WorldFwk)
89  KY_CLASS_WITHOUT_COPY(ScopedPerformedQueryCounter)
90 public:
91  ScopedPerformedQueryCounter(QueryType queryType, Database* database, PerformQueryStat queryStat);
92 
93  ~ScopedPerformedQueryCounter() { ++m_counter; }
94 
95 private:
96  KyUInt32& m_counter;
97 };
98 
99 #else // KY_CONFIG_RELEASE is defined
100 
101 class PerformQueryStatistics
102 {
103  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_WorldFwk)
104 public:
105  void ResetPerformQueryCounter() {}
106  void Report(StringBuffer*, QueryStatReportType reportType = QueryStatReport_RelevantOnly) const { KY_UNUSED(reportType); }
107  void Initialize() {}
108 };
109 
110 class ScopedPerformedQueryCounter
111 {
112  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_WorldFwk)
113 public:
114  ScopedPerformedQueryCounter(QueryType, Database*, PerformQueryStat) {}
115  ~ScopedPerformedQueryCounter() {}
116 };
117 #endif
118 
119 }
120 
121 
The report will prune PerformQueryStat with no count.
Definition: querystatistics.h:40
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:196
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
QueryType
Enumerates all the type of query.
Definition: iquery.h:25
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
QueryStatReportType
Definition: querystatistics.h:37
PerformQueryStat
Definition: iquery.h:62