-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatimer.h
65 lines (50 loc) · 926 Bytes
/
gatimer.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef __GATIMER_H__
#define __GATIMER_H__
#include <sys/time.h>
//#include "gautils.h"
class gaTimer
{
long time, oldtime;
public:
gaTimer()
{
struct timeval t;
struct timezone tz;
gettimeofday(&t, &tz);
time=t.tv_sec+(t.tv_usec/1000000);
oldtime=time;
}
~gaTimer() {}
void ResetTimer()
{
struct timeval t;
struct timezone tz;
gettimeofday(&t, &tz);
time=t.tv_sec+(t.tv_usec/1000000);
oldtime=time;
}
void SetTimer(long _time)
{
struct timeval t;
struct timezone tz;
gettimeofday(&t, &tz);
time=t.tv_sec+(t.tv_usec/1000000);
oldtime=time -_time;
}
long ReadTimer()
{
UpdateTimer();
return (time-oldtime);
}
void UpdateTimer()
{
// if(GAPAUSE==false)
{
struct timeval t;
struct timezone tz;
gettimeofday(&t, &tz);
time=t.tv_sec+(t.tv_usec/1000000);
}
}
};
#endif