21 #include <spot/misc/common.hh>
22 #include <spot/misc/_config.h>
28 #if __has_include(<sys/times.h>)
29 # include <sys/times.h>
45 typedef std::chrono::steady_clock
clock;
60 auto t = clock::now();
61 typedef std::chrono::duration<double> seconds;
62 return std::chrono::duration_cast<seconds>(t -
start_).count();
97 #ifdef SPOT_HAVE_TIMES
113 auto end = std::chrono::steady_clock::now();
115 <std::chrono::milliseconds>(end -
wall_start_).count();
116 #ifdef SPOT_HAVE_TIMES
176 clock_t
get_uscp(
bool user,
bool system,
bool children,
bool parent)
const
183 if (user && children)
186 if (system && parent)
189 if (system && children)
207 std::chrono::milliseconds::rep
253 tm[name].first.stop();
266 tm_type::iterator i =
tm.find(name);
267 if (SPOT_UNLIKELY(i ==
tm.end()))
268 throw std::invalid_argument(
"timer_map::cancel(): unknown name");
269 SPOT_ASSERT(0 < i->second.second);
270 if (0 == --i->second.second)
276 timer(
const std::string& name)
const
278 tm_type::const_iterator i =
tm.find(name);
279 if (SPOT_UNLIKELY(i ==
tm.end()))
280 throw std::invalid_argument(
"timer_map::timer(): unknown name");
281 return i->second.first;
296 SPOT_API std::ostream&
308 typedef std::map<std::string, item_type>
tm_type;
327 walltime_lap_ = walltimer.
stop();
334 return walltime_lap_;
338 clock_t
cputime(
bool user,
bool system,
bool children,
bool parent)
const
340 return cputimer.
get_uscp(user, system, children, parent);
346 double walltime_lap_ = 0;
A map of timer, where each timer has a name.
Definition: timer.hh:231
std::pair< spot::timer, int > item_type
Timer + count pair.
Definition: timer.hh:307
std::ostream & print(std::ostream &os) const
Format information about all timers in a table.
bool empty() const
Whether there is no timer in the map.
Definition: timer.hh:290
void stop(const std::string &name)
Stop timer name.
Definition: timer.hh:251
void start(const std::string &name)
Start a timer with name name.
Definition: timer.hh:240
tm_type tm
The map of named timers.
Definition: timer.hh:309
void cancel(const std::string &name)
Cancel timer name.
Definition: timer.hh:264
void reset_all()
Remove information about all timers.
Definition: timer.hh:301
std::map< std::string, item_type > tm_type
Timer map type.
Definition: timer.hh:308
const spot::timer & timer(const std::string &name) const
Return the timer name.
Definition: timer.hh:276
clock_t stime() const
Return the system time of the current process (without children) of all accumulated interval.
Definition: timer.hh:157
std::chrono::milliseconds::rep walltime() const
Return cumulative wall time.
Definition: timer.hh:208
clock_t cutime() const
Return the user time of children of all accumulated interval.
Definition: timer.hh:146
void stop()
Stop a time interval and update the sum of all intervals.
Definition: timer.hh:111
bool is_running() const
Whether the timer is running.
Definition: timer.hh:197
time_info total_
Accumulated time across all intervals.
Definition: timer.hh:215
clock_t cstime() const
Return the system time of children of all accumulated interval.
Definition: timer.hh:167
void start()
Start a time interval.
Definition: timer.hh:92
time_info start_
Start time of the current interval.
Definition: timer.hh:214
clock_t get_uscp(bool user, bool system, bool children, bool parent) const
Definition: timer.hh:176
std::chrono::steady_clock::time_point wall_start_
Wall-clock start time of the current interval.
Definition: timer.hh:218
clock_t utime() const
Return the user time of the current process (without children) of all accumulated interval.
Definition: timer.hh:136
bool running
Definition: timer.hh:216
std::chrono::milliseconds::rep wall_cumul_
Wall time sum.
Definition: timer.hh:219
Definition: automata.hh:26
struct spot::process_timer process_timer
Struct used to start and stop both timer and stopwatch clocks.
std::ostream & operator<<(std::ostream &os, const mc_algorithm &ma)
Print an mc_algorithm value to a stream.
Definition: mc.hh:74
Struct used to start and stop both timer and stopwatch clocks.
Definition: timer.hh:314
void stop()
Stop both timers and record elapsed times.
Definition: timer.hh:325
double walltime() const
Return elapsed wall time in seconds since the last start().
Definition: timer.hh:332
void start()
Start both wall-clock and CPU timers.
Definition: timer.hh:316
clock_t cputime(bool user, bool system, bool children, bool parent) const
Return accumulated CPU ticks for selected time components.
Definition: timer.hh:338
A simple stopwatch.
Definition: timer.hh:42
void start()
Marks the start of the measurement.
Definition: timer.hh:49
std::chrono::steady_clock clock
Clock type used by the stopwatch.
Definition: timer.hh:45
clock::time_point start_
Recorded start time point.
Definition: timer.hh:46
double stop()
Returns the elapsed duration in seconds.
Definition: timer.hh:58
A structure to record elapsed time in clock ticks.
Definition: timer.hh:68
clock_t cstime
System time of child processes.
Definition: timer.hh:76
clock_t cutime
User time of child processes.
Definition: timer.hh:75
clock_t stime
System time of the process.
Definition: timer.hh:74
clock_t utime
User time of the process.
Definition: timer.hh:73