Mass++ Common Libraries v2.7.5
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Enumerations
Macros
CoreToolkits
Timer.cpp
Go to the documentation of this file.
1
12
#include "stdafx.h"
13
#include "
Timer.h
"
14
15
#include <ctime>
16
17
18
using namespace
kome::core;
19
20
21
#include <crtdbg.h>
22
#ifdef _DEBUG
23
#define new new( _NORMAL_BLOCK, __FILE__, __LINE__ )
24
#define malloc( s ) _malloc_dbg( s, _NORMAL_BLOCK, __FILE__, __LINE__ )
25
#endif // _DEBUG
26
27
28
29
// constructor
30
Timer::Timer
() {
31
reset
();
32
}
33
34
// destrctor
35
Timer::~Timer
() {
36
}
37
38
// reset timer
39
void
Timer::reset
() {
40
m_total
= 0.0;
41
m_start
= 0;
42
m_stopped
=
true
;
43
}
44
45
// start timer
46
void
Timer::start
() {
47
m_start
= std::clock();
48
m_stopped
=
false
;
49
}
50
51
// stop timer
52
double
Timer::stop
() {
53
// total time
54
const
double
t =
getTime
();
55
m_total
+=
getTime
();
56
57
// set start time
58
m_start
= std::clock();
59
60
// stopped
61
m_stopped
=
true
;
62
63
return
t;
64
}
65
66
// get time
67
double
Timer::getTime
() {
68
// get time
69
double
t = 0.0;
70
71
if
( !
m_stopped
) {
72
// current
73
clock_t current = std::clock();
74
75
// time
76
t = (double)( current -
m_start
) / (double)( CLOCKS_PER_SEC );
77
}
78
79
return
t;
80
}
81
82
// get total time
83
double
Timer::getTotalTime
() {
84
double
t =
m_total
;
85
t +=
getTime
();
86
return
t;
87
}
kome::core::Timer::getTime
double getTime()
gets time
Definition:
Timer.cpp:67
kome::core::Timer::m_total
double m_total
Definition:
Timer.h:45
kome::core::Timer::start
void start()
starts timer
Definition:
Timer.cpp:46
Timer.h
interfaces of Timer class
kome::core::Timer::~Timer
virtual ~Timer()
destructor
Definition:
Timer.cpp:35
kome::core::Timer::reset
void reset()
resets timer
Definition:
Timer.cpp:39
kome::core::Timer::Timer
Timer()
constructor
Definition:
Timer.cpp:30
kome::core::Timer::getTotalTime
double getTotalTime()
gets total time
Definition:
Timer.cpp:83
kome::core::Timer::stop
double stop()
stops timer
Definition:
Timer.cpp:52
kome::core::Timer::m_start
clock_t m_start
Definition:
Timer.h:42
kome::core::Timer::m_stopped
bool m_stopped
Definition:
Timer.h:48
Generated on Sun Mar 18 2018 12:32:08 for Mass++ Common Libraries v2.7.5 by
1.8.6