hpp-rbprm 4.15.1
Implementation of RB-PRM planner using hpp.
Loading...
Searching...
No Matches
stop-watch.hh
Go to the documentation of this file.
1/*
2Copyright (c) 2010-2013 Tommaso Urli
3
4Tommaso Urli tommaso.urli@uniud.it University of Udine
5
6Permission is hereby granted, free of charge, to any person obtaining
7a copy of this software and associated documentation files (the
8"Software"), to deal in the Software without restriction, including
9without limitation the rights to use, copy, modify, merge, publish,
10distribute, sublicense, and/or sell copies of the Software, and to
11permit persons to whom the Software is furnished to do so, subject to
12the following conditions:
13
14The above copyright notice and this permission notice shall be
15included in all copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
25*/
26
27#ifndef WBR_STOPWATCH_H
28#define WBR_STOPWATCH_H
29
31
32#ifndef WIN32
33/* The classes below are exported */
34#pragma GCC visibility push(default)
35#endif
36
37// Generic stopwatch exception class
39 public:
41 std::string error;
42};
43
45 NONE = 0, // Clock is not initialized
46 CPU_TIME = 1, // Clock calculates time ranges using ctime and CLOCKS_PER_SEC
47 REAL_TIME = 2 // Clock calculates time by asking the operating system how
48 // much real time passed
49};
50
143 public:
146
149
151 bool performance_exists(std::string perf_name);
152
155
157 void start(std::string perf_name);
158
160 void stop(std::string perf_name);
161
163 void pause(std::string perf_name);
164
166 void reset(std::string perf_name);
167
169 void reset_all();
170
172 void report(std::string perf_name, int precision = 2,
173 std::ostream& output = std::cout);
174
176 void report_all(int precision = 2, std::ostream& output = std::cout);
177
179 long double get_total_time(std::string perf_name);
180
182 long double get_average_time(std::string perf_name);
183
185 long double get_min_time(std::string perf_name);
186
188 long double get_max_time(std::string perf_name);
189
191 long double get_last_time(std::string perf_name);
192
195 long double get_time_so_far(std::string perf_name);
196
199 void turn_off();
200
202 void turn_on();
203
205 long double take_time();
206
207 protected:
211 : clock_start(0),
212 total_time(0),
213 min_time(0),
214 max_time(0),
215 last_time(0),
216 paused(false),
217 stops(0) {}
218
220 long double clock_start;
221
223 long double total_time;
224
226 long double min_time;
227
229 long double max_time;
230
232 long double last_time;
233
235 bool paused;
236
238 int stops;
239 };
240
242 bool active;
243
246
249 std::map<std::string, PerformanceData>* records_of;
250};
251
253
254#ifndef WIN32
255#pragma GCC visibility pop
256#endif
257
258#endif
A class representing a stopwatch.
Definition: stop-watch.hh:142
long double get_time_so_far(std::string perf_name)
long double take_time()
long double get_min_time(std::string perf_name)
long double get_max_time(std::string perf_name)
void reset(std::string perf_name)
long double get_total_time(std::string perf_name)
void set_mode(StopwatchMode mode)
bool performance_exists(std::string perf_name)
void report_all(int precision=2, std::ostream &output=std::cout)
void turn_on()
std::map< std::string, PerformanceData > * records_of
Definition: stop-watch.hh:249
void start(std::string perf_name)
long double get_average_time(std::string perf_name)
bool active
Definition: stop-watch.hh:242
void pause(std::string perf_name)
void reset_all()
Stopwatch(StopwatchMode _mode=NONE)
void stop(std::string perf_name)
void turn_off()
long double get_last_time(std::string perf_name)
StopwatchMode mode
Definition: stop-watch.hh:245
void report(std::string perf_name, int precision=2, std::ostream &output=std::cout)
StopwatchMode
Definition: stop-watch.hh:44
@ CPU_TIME
Definition: stop-watch.hh:46
@ REAL_TIME
Definition: stop-watch.hh:47
@ NONE
Definition: stop-watch.hh:45
Stopwatch & getProfiler()
Definition: stop-watch.hh:38
StopwatchException(std::string error)
Definition: stop-watch.hh:40
std::string error
Definition: stop-watch.hh:41
Definition: stop-watch.hh:209
long double min_time
Definition: stop-watch.hh:226
long double total_time
Definition: stop-watch.hh:223
long double max_time
Definition: stop-watch.hh:229
int stops
Definition: stop-watch.hh:238
bool paused
Definition: stop-watch.hh:235
long double last_time
Definition: stop-watch.hh:232
long double clock_start
Definition: stop-watch.hh:220
PerformanceData()
Definition: stop-watch.hh:210