VR-Forces 5.0.3 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtStatsSet.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2012 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <string>
13 #include <vector>
14 
15 #include <vrvCore/vrvCore.h>
16 #include <vlutil/vlPerformanceStats.h>
17 #include <boost/preprocessor/seq/for_each.hpp>
18 #include <boost/preprocessor/facilities/expand.hpp>
19 
20 namespace makVrv
21 {
38 #define DT_DECLARE_STATS_SET(name, id, stats_elements)\
39  DT_STATSSET_DECLARE_ENUM(id, stats_elements)\
40  \
41  void init##id##Stats(makVrv::DtPerformanceStatsManager& mgr)\
42  {\
43  static bool guard = false;\
44  guard = true;\
45  makVrv::DtStatsSet* id##_statsSet = new makVrv::DtStatsSet();\
46  id##_statsSet->myName = name;\
47  BOOST_PP_SEQ_FOR_EACH(DT_STATSSET_ADD, id##_statsSet, stats_elements)\
48  mgr.add(name, id##_statsSet);\
49  }\
50 
51 #define DT_STATSSET_QUOTE(x) #x
52 #define DT_STATSSET_ENUM(r, name, elem) BOOST_PP_CAT(timer, BOOST_PP_CAT(_, BOOST_PP_CAT(name, BOOST_PP_CAT(_, elem)))),
53 #define DT_STATSSET_ADD(r, stats_set_ptr, elem) stats_set_ptr->addStats(DT_STATSSET_QUOTE(elem));
54 #define DT_STATSSET_DECLARE_ENUM(name, seq) enum TimerStats_##name { BOOST_PP_SEQ_FOR_EACH(DT_STATSSET_ENUM, name, seq) timer_##name##_end};
55 
58  {
59  std::string myDescription;
60  DtTimeStatistic myStatistic;
61  };
62 
66  {
67  public:
69  void addStats(const std::string& name);
70 
74  void startFrame();
75 
79  void endFrame(double frameDuration);
80 
84  void addTime(unsigned int index, double t);
85 
86  std::vector<DtTimeStat> myStats;
87  double myTotalTime;
88  std::vector<double> myPerFrameStats;
90  std::string myName;
91  };
92 
99  {
100  public:
102  ScopedStatTimer(unsigned int timerIndex, makVrv::DtStatsSet& statsSet);
103 
105  virtual ~ScopedStatTimer();
106 
107  protected:
110  unsigned int myIndex;
111  };
112 
115 #define DT_SCOPED_STAT_TIMER(stats_element, stats_set_id, stats_set_ref)\
116  ScopedStatTimer scopedStatTimer_##stats_element(timer_##stats_set_id##_##stats_element, stats_set_ref)
117 }
std::vector< DtTimeStat > myStats
Definition: DtStatsSet.h:86
std::string myName
Definition: DtStatsSet.h:90
Utility class for timing a scope block.
Definition: DtStatsSet.h:98
unsigned int myIndex
Definition: DtStatsSet.h:110
Set of performance statistics for display.
Definition: DtStatsSet.h:65
double myTotalTime
Definition: DtStatsSet.h:87
DtPerformanceStats myStatsTimer
Definition: DtStatsSet.h:89
std::string myDescription
Definition: DtStatsSet.h:59
makVrv::DtStatsSet & myStatsSet
Definition: DtStatsSet.h:109
#define DT_DLL_VRVCORE
Definition: vrvCore.h:20
std::vector< double > myPerFrameStats
Definition: DtStatsSet.h:88
Definition of a names set of timing samples.
Definition: DtStatsSet.h:57
DtTimeStatistic myStatistic
Definition: DtStatsSet.h:60
DtTimedSection myTimedSection
Definition: DtStatsSet.h:108
A stats which shows the IG&#39;s performance stats.
Definition: DtPerformanceStats.h:28
Contains DLL export macros.

Document ID: Generated on Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)