MCPcopy Create free account
hub / github.com/antmachineintelligence/mtgbmcode / perf_timer

Class perf_timer

compute/perf/perf.hpp:49–97  ·  view source on GitHub ↗

a simple timer wrapper which records multiple time entries

Source from the content-addressed store, hash-verified

47
48// a simple timer wrapper which records multiple time entries
49class perf_timer
50{
51public:
52 typedef boost::timer::nanosecond_type nanosecond_type;
53
54 perf_timer()
55 {
56 timer.stop();
57 }
58
59 void start()
60 {
61 timer.start();
62 }
63
64 void stop()
65 {
66 timer.stop();
67 times.push_back(timer.elapsed().wall);
68 }
69
70 size_t trials() const
71 {
72 return times.size();
73 }
74
75 void clear()
76 {
77 times.clear();
78 }
79
80 nanosecond_type last_time() const
81 {
82 return times.back();
83 }
84
85 nanosecond_type min_time() const
86 {
87 return *std::min_element(times.begin(), times.end());
88 }
89
90 nanosecond_type max_time() const
91 {
92 return *std::max_element(times.begin(), times.end());
93 }
94
95 boost::timer::cpu_timer timer;
96 std::vector<boost::timer::nanosecond_type> times;
97};
98
99// returns the rate (in MB/s) for processing 'count' items of type 'T'
100// in 'time' nanoseconds

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected