-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer.h
More file actions
41 lines (26 loc) · 713 Bytes
/
timer.h
File metadata and controls
41 lines (26 loc) · 713 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
/***********************************************************
CSC418, FALL 2009
timer.h
author: Mike Pratscher
Timer class
Provides a timer to drive the animation based
on time rather than frame rate.
***********************************************************/
#ifndef __TIMER_H__
#define __TIMER_H__
#include <time.h>
class Timer
{
public:
// constructor
Timer() { reset(); }
// destructor
virtual ~Timer() {}
// start the timer
void reset() { startTime = clock(); }
// query elapsed time
double elapsed() const { return (double(clock() - startTime) / double(CLOCKS_PER_SEC)); }
private:
clock_t startTime;
};
#endif // __TIMER_H__