src
Util
StopWatch.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2012 SCHUNK GmbH & Co. KG
3
* Copyright (c) 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*/
17
18
#ifndef UTIL_STOPWATCH_H
19
#define UTIL_STOPWATCH_H
20
21
// ---- local includes ------------------------------------------------------ ;
22
23
#include "../Util/Message.h"
24
25
// ---- global includes ----------------------------------------------------- ;
26
27
// ---- remap, typedefs ----------------------------------------------------- ;
28
29
enum
util_TimeMeasurementType
{
30
util_CPU_TIME
,
31
util_REAL_TIME
32
};
33
34
// ---- class definition ---------------------------------------------------- ;
35
36
/*
37
stopwatch features
38
This class allows to measure discrete time intervalls in your program.
39
*/
40
class
CStopWatch
:
public
CMessage
41
{
42
43
protected
:
44
45
// ---- protected datas ------------------------------------------------ ;
46
47
long
m_iFirst
;
48
long
m_iLast
;
49
double
m_fOverflowTime
;
50
51
#if defined(__QNX__)
52
timespec
m_FirstTime
;
53
timespec
m_LastTime
;
54
timespec
m_TempTime
;
55
timespec
m_ActualTime
;
56
#elif defined(_WIN32)
57
double
frequencyE;
58
LARGE_INTEGER
m_FirstTime
;
59
LARGE_INTEGER
m_LastTime
;
60
LARGE_INTEGER
m_TempTime
;
61
LARGE_INTEGER
m_ActualTime
;
62
#else
63
timeval
m_FirstTime
;
64
timeval
m_LastTime
;
65
timeval
m_TempTime
;
66
timeval
m_ActualTime
;
67
#endif
68
69
bool
m_bStartFlag
;
70
bool
m_bStopFlag
;
71
72
util_TimeMeasurementType
m_iTimeType
;
73
74
// ---- auxiliary functions ----------------------------------------------- ;
75
76
public
:
77
78
// ---- public datas ------------------------------------------------------ ;
79
80
// ---- constructor/destructor -------------------------------------------- ;
81
82
// default constructor with timetype util_REAL_TIME
83
CStopWatch
();
84
85
86
// constructor
87
CStopWatch
(
util_TimeMeasurementType
iTimeType);
88
89
// copy constructor
90
CStopWatch
(
const
CStopWatch
& );
91
92
// ---- operators --------------------------------------------------------- ;
93
94
// assignment operator
95
CStopWatch
&
operator=
(
const
CStopWatch
& );
96
97
// ---- query functions --------------------------------------------------- ;
98
99
// returns the time type
100
util_TimeMeasurementType
timeType
()
const
;
101
102
// ---- modify functions -------------------------------------------------- ;
103
104
// sets the time type
105
void
timeType
(
const
util_TimeMeasurementType
& riTimeType);
106
107
// ---- I/O --------------------------------------------------------------- ;
108
109
// returns the difference between start and stop time in [s]
110
double
executionTime
();
111
112
// returns the real time in [s]
113
double
realTime
();
114
115
// returns the real time resolution in [s]
116
double
realTimeResolution
();
117
118
// ---- exec functions ---------------------------------------------------- ;
119
120
// sets start time to current clock value
121
void
start
();
122
123
// sets stop time to current clock value
124
void
stop
();
125
126
// continues after a call of stop()
127
void
cont
();
128
129
// wait realtime in [ms]
130
void
wait
(
unsigned
int
uiTime);
131
132
// returns the current date
133
void
date
(
char
* acDate)
const
;
134
135
// returns the current weekday
136
void
weekday
(
char
* acWeekday)
const
;
137
138
// tests, if there is an overflow at clock counter
139
void
testOverflow
();
140
};
141
142
// ---- extern I/O ---------------------------------------------------------- ;
143
144
// ---- public inline functions --------------------------------------------- ;
145
146
inline
util_TimeMeasurementType
CStopWatch::timeType
()
const
147
{
148
return
(
m_iTimeType
);
149
};
150
151
inline
void
CStopWatch::timeType
(
const
util_TimeMeasurementType
& riTimeType)
152
{
153
m_iTimeType
= riTimeType;
154
};
155
156
// -------------------------------------------------------------------------- ;
157
158
#endif // UTIL_STOPWATCH_H
CStopWatch::executionTime
double executionTime()
Definition:
StopWatch.cpp:166
CStopWatch::m_bStartFlag
bool m_bStartFlag
Definition:
StopWatch.h:69
CStopWatch::m_TempTime
timeval m_TempTime
Definition:
StopWatch.h:65
CStopWatch::start
void start()
Definition:
StopWatch.cpp:211
CStopWatch::date
void date(char *acDate) const
Definition:
StopWatch.cpp:379
CStopWatch::m_ActualTime
timeval m_ActualTime
Definition:
StopWatch.h:66
util_CPU_TIME
@ util_CPU_TIME
Definition:
StopWatch.h:30
CStopWatch
Definition:
StopWatch.h:40
CStopWatch::timeType
util_TimeMeasurementType timeType() const
Definition:
StopWatch.h:146
util_TimeMeasurementType
util_TimeMeasurementType
Definition:
StopWatch.h:29
CStopWatch::m_fOverflowTime
double m_fOverflowTime
Definition:
StopWatch.h:49
CStopWatch::CStopWatch
CStopWatch()
Definition:
StopWatch.cpp:38
CStopWatch::realTimeResolution
double realTimeResolution()
Definition:
StopWatch.cpp:315
CMessage
Definition:
Message.h:46
CStopWatch::m_bStopFlag
bool m_bStopFlag
Definition:
StopWatch.h:70
CStopWatch::operator=
CStopWatch & operator=(const CStopWatch &)
Definition:
StopWatch.cpp:135
CStopWatch::m_iFirst
long m_iFirst
Definition:
StopWatch.h:47
CStopWatch::testOverflow
void testOverflow()
Definition:
StopWatch.cpp:422
CStopWatch::stop
void stop()
Definition:
StopWatch.cpp:236
CStopWatch::wait
void wait(unsigned int uiTime)
Definition:
StopWatch.cpp:333
CStopWatch::m_iTimeType
util_TimeMeasurementType m_iTimeType
Definition:
StopWatch.h:72
CStopWatch::weekday
void weekday(char *acWeekday) const
Definition:
StopWatch.cpp:400
CStopWatch::m_iLast
long m_iLast
Definition:
StopWatch.h:48
CStopWatch::m_FirstTime
timeval m_FirstTime
Definition:
StopWatch.h:63
util_REAL_TIME
@ util_REAL_TIME
Definition:
StopWatch.h:31
CStopWatch::m_LastTime
timeval m_LastTime
Definition:
StopWatch.h:64
CStopWatch::realTime
double realTime()
Definition:
StopWatch.cpp:299
CStopWatch::cont
void cont()
Definition:
StopWatch.cpp:268
schunk_libm5api
Author(s): Florian Weisshardt
autogenerated on Sat May 7 2022 02:17:13