Caffe
benchmark.hpp
1 #ifndef CAFFE_UTIL_BENCHMARK_H_
2 #define CAFFE_UTIL_BENCHMARK_H_
3 
4 #include <boost/date_time/posix_time/posix_time.hpp>
5 
6 #include "caffe/util/device_alternate.hpp"
7 
8 namespace caffe {
9 
10 class Timer {
11  public:
12  Timer();
13  virtual ~Timer();
14  virtual void Start();
15  virtual void Stop();
16  virtual float MilliSeconds();
17  virtual float MicroSeconds();
18  virtual float Seconds();
19 
20  inline bool initted() { return initted_; }
21  inline bool running() { return running_; }
22  inline bool has_run_at_least_once() { return has_run_at_least_once_; }
23 
24  protected:
25  void Init();
26 
27  bool initted_;
28  bool running_;
29  bool has_run_at_least_once_;
30 #ifndef CPU_ONLY
31  cudaEvent_t start_gpu_;
32  cudaEvent_t stop_gpu_;
33 #endif
34  boost::posix_time::ptime start_cpu_;
35  boost::posix_time::ptime stop_cpu_;
36  float elapsed_milliseconds_;
37  float elapsed_microseconds_;
38 };
39 
40 class CPUTimer : public Timer {
41  public:
42  explicit CPUTimer();
43  virtual ~CPUTimer() {}
44  virtual void Start();
45  virtual void Stop();
46  virtual float MilliSeconds();
47  virtual float MicroSeconds();
48 };
49 
50 } // namespace caffe
51 
52 #endif // CAFFE_UTIL_BENCHMARK_H_
Definition: benchmark.hpp:10
A layer factory that allows one to register layers. During runtime, registered layers can be called b...
Definition: blob.hpp:14
Definition: benchmark.hpp:40