00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef LUX_TIMER_H
00024 #define LUX_TIMER_H
00025
00026 #include "lux.h"
00027 #if defined ( WIN32 ) || defined(__CYGWIN__)
00028 #include <windows.h>
00029 #else
00030 #include <sys/time.h>
00031 #endif
00032 #if (_MSC_VER >= 1400)
00033 #include <stdio.h>
00034 #define snprintf _snprintf
00035 #endif
00036
00037 class Timer {
00038 public:
00039
00040 Timer();
00041 ~Timer();
00042
00043 void Start();
00044 void Stop();
00045 void Reset();
00046
00047 double Time();
00048 private:
00049
00050 double time0, elapsed;
00051 bool running;
00052 double GetTime();
00053 #if defined( IRIX ) || defined( IRIX64 )
00054
00055 int fd;
00056 unsigned long long counter64;
00057 unsigned int counter32;
00058 unsigned int cycleval;
00059
00060 typedef unsigned long long iotimer64_t;
00061 typedef unsigned int iotimer32_t;
00062 volatile iotimer64_t *iotimer_addr64;
00063 volatile iotimer32_t *iotimer_addr32;
00064
00065 void *unmapLocation;
00066 int unmapSize;
00067 #elif defined( WIN32 ) || defined(__CYGWIN__)
00068
00069 LARGE_INTEGER performance_counter, performance_frequency;
00070 double one_over_frequency;
00071 #else
00072
00073 struct timeval timeofday;
00074 #endif
00075 };
00076 #endif // LUX_TIMER_H