timetrack.h

来自「clique code with sample data set. clique」· C头文件 代码 · 共 35 行

H
35
字号
#include <sys/time.h>
#include <unistd.h>  

#define microsec 1000000.0

class TimeTracker {
private:
   struct timeval start_time;
   struct timeval stop_time;
   bool  running;
public:
   TimeTracker() {
      running=false;
   }
   
   void Start() {
      gettimeofday(&start_time, (struct timezone *)0);
      running=true;
   }
   
  double Stop() {
     double st, en;
     if (!running) return(-1.0);
     else {
        gettimeofday(&stop_time, (struct timezone *)0);
        st = start_time.tv_sec + (start_time.tv_usec/microsec);
        en = stop_time.tv_sec + (stop_time.tv_usec/microsec);
        running=false;
        return (double)(en - st);
     }
  }
};


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?