-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer.h
More file actions
49 lines (37 loc) · 882 Bytes
/
Copy pathtimer.h
File metadata and controls
49 lines (37 loc) · 882 Bytes
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
/**************************************************************
This code is a part of a course on cuda taught by the author:
Lokman A. Abbas-Turki
Those who re-use this code should mention in their code
the name of the author above.
***************************************************************/
#ifndef SEEK_SET
#define SEEK_SET 0
#endif
#ifndef CLOCKS_PER_SEC
#include <unistd.h>
#define CLOCKS_PER_SEC _SC_CLK_TCK
#endif
class Timer {
private:
double _start;
double sum;
public:
Timer(void) : _start(0.0), sum(0.0) {
}
public:
inline void start(void) {
_start = clock();
}
inline void add(void) {
sum += (clock() - _start)/(double)CLOCKS_PER_SEC;
}
inline double getstart(void) const {
return _start;
}
inline double getsum(void) const {
return sum;
}
inline void reset(void) {
sum = 0.0;
}
};