VR-Link API Documentation for HLA 1.3
Home
Namespaces
Classes
Files
Examples
Libraries
File List
File Members
include
vlutil
vlPerformanceStats.h
Go to the documentation of this file.
1
/******************************************************************************
2
** Copyright (c) 1992-2010 VT MAK
3
** All rights reserved.
4
******************************************************************************/
10
#pragma once
11
12
#include "
vlUtil.h
"
13
#include <vector>
14
15
#ifdef _WIN32
16
#else
17
#include <sys/time.h>
18
#endif
19
20
#ifdef DtUSE_UTILITIES_NAMESPACE
21
namespace
DtUSE_UTILITIES_NAMESPACE
22
{
23
#endif
24
32
class
DT_DLL_VLUTIL
DtTimedSection
33
{
34
public
:
36
DtTimedSection
();
37
39
void
start();
40
42
void
stop();
43
49
double
duration()
const
;
50
51
protected
:
52
53
//Platform specific storage times, and additional members.
54
#ifdef _WIN32
55
typedef
LARGE_INTEGER
TimeValue
;
56
double
myInverseFrequency;
57
#else
58
typedef
timeval
TimeValue
;
59
struct
timezone tz;
60
#endif
61
62
TimeValue
myStartVal
;
63
TimeValue
myEndVal
;
64
};
65
75
class
DT_DLL_VLUTIL
DtTimeStatistic
76
{
77
public
:
78
80
DtTimeStatistic
();
81
83
void
addTime(
double
time);
84
86
inline
double
last()
const
87
{
88
return
myLastTime;
89
}
90
92
inline
double
minimum()
const
93
{
94
return
myMinimum;
95
}
96
99
inline
double
avg()
const
100
{
101
// Calculate the average by taking the running Avg scaled by the max
102
// count plus the current average scaled by the count/ over the total count;
103
return
(myLastSum + mySum) / (double)(myLastCount + myCount);
104
}
105
107
inline
double
maximum()
const
108
{
109
return
myMaximum;
110
}
111
113
void
reset();
114
115
protected
:
116
double
myLastTime
;
117
double
myMinimum
;
118
double
mySum
;
119
double
myLastSum
;
120
double
myMaximum
;
121
unsigned
int
myCount
;
122
unsigned
int
myLastCount
;
123
static
const
int
theMaxCount = 1000;
124
};
125
133
class
DT_DLL_VLUTIL
DtPerformanceStats
134
{
135
public
:
136
//A vector of stats.
137
typedef
std::vector<DtTimeStatistic>
TimeStats
;
138
139
//Create a time stat list.
140
DtPerformanceStats
();
141
142
//Destroy a time stat list.
143
~
DtPerformanceStats
();
144
146
void
resetAllStats();
147
149
inline
void
addTime(
unsigned
int
id
,
double
time)
150
{
151
stat(
id
).addTime(time);
152
}
153
155
inline
double
last(
unsigned
int
id
)
const
156
{
157
return
stat(
id
).last();
158
}
159
161
inline
double
minimum(
unsigned
int
id
)
const
162
{
163
return
stat(
id
).minimum();
164
}
165
167
inline
double
avg(
unsigned
int
id
)
const
168
{
169
return
stat(
id
).avg();
170
}
171
173
inline
double
maximum(
unsigned
int
id
)
const
174
{
175
return
stat(
id
).maximum();
176
}
177
186
DtTimeStatistic
& stat(
unsigned
int
statEnumIndex);
187
const
DtTimeStatistic
& stat(
unsigned
int
statEnumIndex)
const
;
188
190
191
TimeStats& stats();
192
const
TimeStats& stats()
const
;
194
195
protected
:
196
TimeStats
myStats
;
197
};
198
199
#ifdef DtUSE_UTILITIES_NAMESPACE
200
}
201
#endif
202
Document ID: Generated on Wed Aug 14 15:35:11 EDT 2013 from SVN revision 130445
Copyright © 2005-2013 VT MÄK. All Rights Reserved (
www.mak.com
)