src/work/marci/time_measure.h
changeset 195 19f8bd411014
parent 124 8d24100ad408
child 259 509ba9f136d2
equal deleted inserted replaced
4:054f08cc9cb9 5:00529327b37b
    95 class Timer
    95 class Timer
    96 {
    96 {
    97   TimeStamp start_time;
    97   TimeStamp start_time;
    98 
    98 
    99   void _reset() {start_time.stamp();}
    99   void _reset() {start_time.stamp();}
   100 
   100   
   101 public: 
   101 public: 
   102   Timer() {_reset();}
   102   Timer() {_reset();}
   103 
   103 
   104   operator TimeStamp ()
   104   operator TimeStamp ()
   105   {
   105   {
   106     TimeStamp t;
   106     TimeStamp t;
   107     t.stamp();
   107     t.stamp();
   108     return t-start_time;
   108     return t-start_time;
   109   }
   109   }
   110   
   110 
   111   TimeStamp reset()
   111   TimeStamp reset()
   112   {
   112   {
   113     TimeStamp t(start_time);
   113     TimeStamp t(start_time);
   114     _reset();
   114     _reset();
   115     return start_time-t;
   115     return start_time-t;
   116   }
   116   }
   117 
       
   118 };
   117 };
   119 
   118 
   120 inline std::ostream& operator<<(std::ostream& os,const TimeStamp &t)
   119 inline std::ostream& operator<<(std::ostream& os,const TimeStamp &t)
   121 {
   120 {
   122   long cls = sysconf(_SC_CLK_TCK);
   121   long cls = sysconf(_SC_CLK_TCK);