00001 #ifndef MISC_TIMER_H
00002 #define MISC_TIMER_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00034 #include <glt/config.h>
00035
00036 #include <ctime>
00037 #include <iosfwd>
00038
00039 #ifdef GLT_UNIX
00040 #include <sys/time.h>
00041 #endif
00042
00060 class Timer
00061 {
00062 public:
00063
00064
00065
00066
00068 Timer();
00070 Timer(std::ostream &);
00072 ~Timer();
00073
00075 double elapsed() const;
00076
00078 clock_t clock() const;
00079
00081 void start();
00082
00083
00084
00085
00086
00087
00089 static void freeze();
00090
00092 static void unFreeze();
00093
00095 static void advance(const uint32 msec);
00096
00097 private:
00098
00099 #ifdef GLT_WIN32
00100 clock_t _start;
00101 clock_t _end;
00102 static clock_t _frozen;
00103 #endif
00104
00105 #ifdef GLT_UNIX
00106 timeval _start;
00107 timeval _end;
00108 static timeval _frozen;
00109 #endif
00110
00111 static uint32 _frozenCount;
00112
00113 std::ostream *_os;
00114 };
00115
00116 #endif