clray
changeset 33:931d13b72f83
forgot to add the timers
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 24 Aug 2010 05:47:04 +0100 |
parents | 4cf4919c3812 |
children | a218551293ad 7d77ded5f890 |
files | src/timer.cc src/timer.h |
diffstat | 2 files changed, 36 insertions(+), 0 deletions(-) [+] |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/timer.cc Tue Aug 24 05:47:04 2010 +0100 1.3 @@ -0,0 +1,30 @@ 1.4 +#include "timer.h" 1.5 + 1.6 +#if defined(unix) || defined(__unix__) || defined(__APPLE__) 1.7 +#include <unistd.h> 1.8 +#include <sys/time.h> 1.9 + 1.10 +long get_msec() 1.11 +{ 1.12 + static struct timeval tv0; 1.13 + struct timeval tv; 1.14 + 1.15 + gettimeofday(&tv, 0); 1.16 + 1.17 + if(tv0.tv_sec == 0 && tv0.tv_usec == 0) { 1.18 + tv0 = tv; 1.19 + return 0; 1.20 + } 1.21 + return (tv.tv_sec - tv0.tv_sec) * 1000L + (tv.tv_usec - tv0.tv_usec) / 1000L; 1.22 +} 1.23 + 1.24 +#elif defined(WIN32) || defined(__WIN32__) 1.25 +#include <windows.h> 1.26 + 1.27 +#pragma comment(lib, "winmm.lib") 1.28 + 1.29 +long get_msec() 1.30 +{ 1.31 + return timeGetTime(); 1.32 +} 1.33 +#endif