libcrbn/timer.hpp

00001 
00002 #ifndef __CRBN_timer_hpp__
00003 #define __CRBN_timer_hpp__
00004 
00005 #include <sys/time.h>
00006 
00007 class Timer
00008 {
00009  public:
00010   Timer() {}
00011   void start() {
00012     struct timeval tt;
00013     gettimeofday( &tt, NULL );
00014     _start = tt.tv_sec * 1000 + tt.tv_usec / 1000;
00015   }
00016 
00017   long stop() {
00018     struct timeval tt;
00019     gettimeofday( &tt, NULL );
00020     return (tt.tv_sec * 1000 + tt.tv_usec / 1000) - _start;
00021   }
00022 
00023   long top() {
00024     struct timeval tt;
00025     gettimeofday( &tt, NULL );
00026     long ll = tt.tv_sec * 1000 + tt.tv_usec / 1000;
00027     long lll = ll - _start;
00028     _start = ll;
00029     return lll;
00030   }
00031 private:
00032   long _start;
00033 };
00034 
00035 
00036 #endif // __CRBN_timer_hpp__

Generated on Tue Nov 14 15:40:08 2006 for libcrbn by  doxygen 1.5.0