LArOpenCV  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
Watch.h
Go to the documentation of this file.
1 #ifndef __LARCV_UTILS_WATCH_H__
2 #define __LARCV_UTILS_WATCH_H__
3 
18 #include <sys/time.h>
19 #include <time.h>
20 
21 namespace larcv {
22 
27  class Watch {
28  public:
29  Watch(){}
30  ~Watch(){}
31 
33  void Start() {
34  // Get current wall time
35  struct timeval current_time;
36  gettimeofday(&current_time,NULL);
37  _wall_time_start = (double)current_time.tv_sec + (double)current_time.tv_usec * 1.e-6;
38  // Get current cpu time
39  _cpu_time_start = (double)(clock());
40  }
42  double WallTime() {
43  // Get current wall time
44  struct timeval current_time;
45  gettimeofday(&current_time,NULL);
46  double now = (double)current_time.tv_sec + (double)current_time.tv_usec * 1.e-6;
47  // Return diff
48  return (now - _wall_time_start);
49  }
51  double CPUTime() {
52  // Get cpu time
53  double now = (double)(clock());
54  // Return diff
55  return (now - _cpu_time_start)/CLOCKS_PER_SEC;
56  }
57  private:
60  };
61 }
62 #endif
63  // end of doxygen group