-
Notifications
You must be signed in to change notification settings - Fork 1
/
timers.cpp
executable file
·34 lines (31 loc) · 959 Bytes
/
timers.cpp
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
//3350 software engineering
//2017
//timer functions
//
#include <unistd.h>
#include <ctime>
//#include <cmath>
#include <cstring>
//-----------------------------------------------------------------------------
//Setup timers
const double physicsRate = 1.0 / 60.0;
const double oobillion = 1.0 / 1e9;
struct timespec timeStart, timeCurrent;
struct timespec timePause;
double physicsCountdown=0.0;
double timeSpan=0.0;
//unsigned int upause=0;
//How to get current time
//clock_gettime(CLOCK_REALTIME, &timeStart);
double timeDiff(struct timespec *start, struct timespec *end)
{
//return the difference in two times.
return (double)(end->tv_sec - start->tv_sec ) +
(double)(end->tv_nsec - start->tv_nsec) * oobillion;
}
void timeCopy(struct timespec *dest, struct timespec *source)
{
//copy one time structure to another.
memcpy(dest, source, sizeof(struct timespec));
}
//-----------------------------------------------------------------------------