You.i Engine
YiProfiler.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2020. All rights reserved.
2 #ifndef _YI_PROFILER_H_
3 #define _YI_PROFILER_H_
4 
5 #include "framework/YiPredef.h"
6 #include "thread/YiSpinLock.h"
8 #include "utility/YiString.h"
9 
15 
31 {
32 public:
36  enum class ReportFormat
37  {
38  PlainText,
39  XML
40  };
41 
45  CYIProfiler(bool threadSafe = false, uint32_t maxProfiles = 20);
46 
50  void ResetProfiles(void);
51 
57  void StartProfile(size_t index);
58 
64  void StopProfile(size_t index);
65 
71  bool AddProfile(size_t index, const CYIString &rName);
72 
78  CYIProfileData *GetProfileData(size_t index) const;
79 
83  void SetMaximumProfiles(uint32_t maxProfiles);
84 
88  size_t GetMaximumProfiles() const;
89 
94 
98  CYIString Report(const std::vector<size_t> indexes, ReportFormat format = ReportFormat::PlainText, CYIProfileData::Accuracy accuracy = CYIProfileData::Accuracy::Milliseconds) const;
99 
100 private:
101  std::vector<std::unique_ptr<std::pair<CYISpinLock, CYIProfileData>>> m_profileData;
102 
103  bool m_threadSafe;
104 };
105 
108 #endif // _YI_PROFILER_H_
bool AddProfile(size_t index, const CYIString &rName)
Container class for Unicode strings. Conceptually, a CYIString object is a sequence of Unicode charac...
Definition: YiString.h:36
Accuracy
Definition: YiProfileData.h:36
size_t GetMaximumProfiles() const
void SetMaximumProfiles(uint32_t maxProfiles)
void ResetProfiles(void)
void StopProfile(size_t index)
CYIString Report(ReportFormat format=ReportFormat::PlainText, CYIProfileData::Accuracy accuracy=CYIProfileData::Accuracy::Milliseconds) const
void StartProfile(size_t index)
This class is used as a profiling or a measurement tool for recurring activities. By marking the begi...
Definition: YiProfileData.h:33
– CYIProfiler
Definition: YiProfiler.h:30
ReportFormat
Definition: YiProfiler.h:36
CYIProfiler(bool threadSafe=false, uint32_t maxProfiles=20)
CYIProfileData * GetProfileData(size_t index) const