VR-Vantage API Documentation
Home
Modules
Namespaces
Classes
Files
Examples
Tutorials
File List
File Members
include
vrvCore
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
57
struct
DT_DLL_VRVCORE
DtTimeStat
58
{
59
std::string
myDescription
;
60
DtTimeStatistic
myStatistic
;
61
};
62
65
class
DT_DLL_VRVCORE
DtStatsSet
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
;
89
DtPerformanceStats
myStatsTimer
;
90
std::string
myName
;
91
};
92
98
class
DT_DLL_VRVCORE
ScopedStatTimer
99
{
100
public
:
102
ScopedStatTimer
(
unsigned
int
timerIndex,
makVrv::DtStatsSet
& statsSet);
103
105
virtual
~
ScopedStatTimer
();
106
107
protected
:
108
DtTimedSection
myTimedSection
;
109
makVrv::DtStatsSet
&
myStatsSet
;
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
}
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (
www.mak.com
)