clray

annotate src/timer.cc @ 55:df239a52a091

extensive render stats for the CPU raytracer
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 11 Sep 2010 03:00:21 +0100
parents
children
rev   line source
nuclear@33 1 #include "timer.h"
nuclear@33 2
nuclear@33 3 #if defined(unix) || defined(__unix__) || defined(__APPLE__)
nuclear@33 4 #include <unistd.h>
nuclear@33 5 #include <sys/time.h>
nuclear@33 6
nuclear@33 7 long get_msec()
nuclear@33 8 {
nuclear@33 9 static struct timeval tv0;
nuclear@33 10 struct timeval tv;
nuclear@33 11
nuclear@33 12 gettimeofday(&tv, 0);
nuclear@33 13
nuclear@33 14 if(tv0.tv_sec == 0 && tv0.tv_usec == 0) {
nuclear@33 15 tv0 = tv;
nuclear@33 16 return 0;
nuclear@33 17 }
nuclear@33 18 return (tv.tv_sec - tv0.tv_sec) * 1000L + (tv.tv_usec - tv0.tv_usec) / 1000L;
nuclear@33 19 }
nuclear@33 20
nuclear@33 21 #elif defined(WIN32) || defined(__WIN32__)
nuclear@33 22 #include <windows.h>
nuclear@33 23
nuclear@33 24 #pragma comment(lib, "winmm.lib")
nuclear@33 25
nuclear@33 26 long get_msec()
nuclear@33 27 {
nuclear@33 28 return timeGetTime();
nuclear@33 29 }
nuclear@33 30 #endif