-
Notifications
You must be signed in to change notification settings - Fork 24
/
benchmark.hpp
52 lines (42 loc) · 1.09 KB
/
benchmark.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef CAFFE_UTIL_BENCHMARK_H_
#define CAFFE_UTIL_BENCHMARK_H_
#include <boost/date_time/posix_time/posix_time.hpp>
#include "caffe/util/device_alternate.hpp"
namespace caffe {
class Timer {
public:
Timer();
virtual ~Timer();
virtual void Start();
virtual void Stop();
virtual float MilliSeconds();
virtual float MicroSeconds();
virtual float Seconds();
inline bool initted() { return initted_; }
inline bool running() { return running_; }
inline bool has_run_at_least_once() { return has_run_at_least_once_; }
protected:
void Init();
bool initted_;
bool running_;
bool has_run_at_least_once_;
#ifndef CPU_ONLY
cudaEvent_t start_gpu_;
cudaEvent_t stop_gpu_;
#endif
boost::posix_time::ptime start_cpu_;
boost::posix_time::ptime stop_cpu_;
float elapsed_milliseconds_;
float elapsed_microseconds_;
};
class CPUTimer : public Timer {
public:
explicit CPUTimer();
virtual ~CPUTimer() {}
virtual void Start();
virtual void Stop();
virtual float MilliSeconds();
virtual float MicroSeconds();
};
} // namespace caffe
#endif // CAFFE_UTIL_BENCHMARK_H_