-
Notifications
You must be signed in to change notification settings - Fork 7
/
CTime.h
46 lines (33 loc) · 782 Bytes
/
CTime.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef _CTIME_H_
#define _CTIME_H_
#include <time.h>
class CTime
{
public:
friend class CTimeDiff;
CTime() : m_time(clock())
{
}
CTime& operator += (int timeMs)
{
m_time += timeMs * (CLOCKS_PER_SEC / 1000);
return *this;
}
bool operator < (const CTime& rhs)
{
return m_time < rhs.m_time;
}
private:
clock_t m_time;
}; // end of class CTime
class CTimeDiff
{
public:
CTimeDiff(const CTime& start) :
m_time(clock() - start.m_time)
{}
unsigned int millisecs() const {return m_time / (CLOCKS_PER_SEC / 1000);}
private:
clock_t m_time;
}; // end of class CTimeDiff
#endif // _CTIME_H_