forked from freudenreichan/info2Praktikum-DobleSpiel
Fix timer
This commit is contained in:
1 file changed
+2
-25
+2
-25
@@ -1,7 +1,7 @@
|
||||
#include "timer.h"
|
||||
|
||||
#if __APPLE__
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
||||
static struct timespec start = {0, 0};
|
||||
|
||||
// Starts the timer.
|
||||
@@ -30,26 +30,3 @@ double stopTimer()
|
||||
|
||||
return measuredSeconds;
|
||||
}
|
||||
#else
|
||||
#include <time.h>
|
||||
static clock_t startClocks = 0;
|
||||
|
||||
// Starts the timer.
|
||||
void startTimer()
|
||||
{
|
||||
startClocks = clock();
|
||||
}
|
||||
|
||||
// Returns the time in seconds since startTimer() was called.
|
||||
double stopTimer()
|
||||
{
|
||||
double measuredSeconds = (clock() - (double)startClocks) / CLOCKS_PER_SEC;
|
||||
|
||||
if(startClocks > 0)
|
||||
startClocks = 0;
|
||||
else
|
||||
measuredSeconds = -1;
|
||||
|
||||
return measuredSeconds;
|
||||
}
|
||||
#endif
|
||||
Reference in new issue
Block a user