gwnavruntime/database/querystatistics.h Source File

querystatistics.h
Go to the documentation of this file.
1 /*
2 * Copyright 2015 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 
8 // primary contact: BRGR - secondary contact: NOBODY
9 
10 #ifndef Navigation_QueryStatistics_H
11 #define Navigation_QueryStatistics_H
12 
16 
17 namespace Kaim
18 {
19 
20 class Database;
21 
22 
23 class PerformQueryStatCounter
24 {
25 public:
26  void Clear();
27  void Increment(QueryType queryType);
28  KyUInt32 GetCount(QueryType queryType) const;
29 
30 public:
31  KyUInt32 m_perQueryCounter[QueryType_FirstCustom];
32 };
33 
35 {
36  QueryStatReport_RelevantOnly,
38 };
39 
54 {
55  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_WorldFwk)
56 public:
57 
61  void Report(StringBuffer* report, QueryStatReportType reportType = QueryStatReport_RelevantOnly) const;
62 
63 
64 public: // internal
65  void Initialize();
66 
67  static const char* GetPerformQueryStatName(PerformQueryStat queryStat);
68 
69  void IncrementPerformQueryStat(PerformQueryStat stat, QueryType queryType);
70  KyUInt32 GetPerformQueryStatCount(PerformQueryStat stat, QueryType queryType);
71  KyUInt32& GetPerformQueryCount(QueryType queryType);
72 
73 public:
76 };
77 
80 {
82 public:
85 
86 private:
87 #ifndef KY_BUILD_SHIPPING
88  KyUInt32& m_counter;
89 #endif
90 };
91 
92 
93 KY_INLINE void PerformQueryStatCounter::Increment(QueryType queryType) { ++m_perQueryCounter[queryType]; }
94 KY_INLINE KyUInt32 PerformQueryStatCounter::GetCount(QueryType queryType) const { return m_perQueryCounter[queryType]; }
95 KY_INLINE void PerformQueryStatCounter::Clear()
96 {
97  for (KyUInt32 i = 0; i < QueryType_FirstCustom; ++i)
98  m_perQueryCounter[i] = 0;
99 }
100 
101 
102 KY_INLINE KyUInt32& PerformQueryStatistics::GetPerformQueryCount(QueryType queryType) { return m_perQueryCounter[queryType]; }
103 KY_INLINE void PerformQueryStatistics::IncrementPerformQueryStat(PerformQueryStat stat, QueryType queryType) { if (stat < PerformQueryStat_Count) m_queryStatCounter[stat].Increment(queryType); }
104 KY_INLINE KyUInt32 PerformQueryStatistics::GetPerformQueryStatCount(PerformQueryStat stat, QueryType queryType) { return m_queryStatCounter[stat].GetCount(queryType); }
105 
106 
107 #ifndef KY_BUILD_SHIPPING
108 KY_INLINE ScopedPerformedQueryCounter::~ScopedPerformedQueryCounter() { ++m_counter; }
109 #else
110 KY_INLINE ScopedPerformedQueryCounter::ScopedPerformedQueryCounter(QueryType, Database*, PerformQueryStat) {}
111 KY_INLINE ScopedPerformedQueryCounter::~ScopedPerformedQueryCounter() {}
112 #endif
113 
114 }
115 
116 #endif
void ResetPerformQueryCounter()
Call This to rest the counters.
The report will prune PerformQueryStat with no count.
Definition: querystatistics.h:39
KyArray< PerformQueryStatCounter > m_queryStatCounter
counter used to determine how many queries of a given QueryType associated to a specific Stat were pe...
Definition: querystatistics.h:84
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:387
void Report(StringBuffer *report, QueryStatReportType reportType=QueryStatReport_RelevantOnly) const
The report will give the total number of calls per PerformQueryStat per QueryType (it is not reported...
KyArray< KyUInt32 > m_perQueryCounter
counter used to determine how many queries of a given QueryType were performed between two calls to R...
Definition: querystatistics.h:83
QueryType
Enumerates all the type of query.
Definition: iquery.h:29
This class is a runtime container for all NavData that represents the world from the point of view of...
Definition: database.h:64
static const char * GetPerformQueryStatName(PerformQueryStat queryStat)
Called by the Database.
Definition: gamekitcrowddispersion.h:20
QueryStatReportType
Definition: querystatistics.h:36
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
PerformQueryStat
Definition: iquery.h:66
This class is used in PerformQuery() or PerformQueryWithInputCoordPos() functions to count the number...
Definition: querystatistics.h:88
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
This class is not instantiated in databases when KY_BUILD_SHIPPING is defined It contains statistics ...
Definition: querystatistics.h:57