OpenMS
2.6.0
|
This class is used to determine the current process' CPU (user and/or kernel) and wall time. More...
#include <OpenMS/SYSTEM/StopWatch.h>
Classes | |
struct | TimeDiff_ |
Public Member Functions | |
void | start () |
Start the stop watch. More... | |
void | stop () |
Stop the stop watch (can be resumed later). If the stop watch was not running an exception is thrown. More... | |
void | resume () |
Resume a stopped StopWatch. More... | |
void | reset () |
Clear the stop watch but keep running. More... | |
void | clear () |
Readout of the StopWatch | |
double | getClockTime () const |
double | getUserTime () const |
double | getSystemTime () const |
double | getCPUTime () const |
Predicates | |
typedef clock_t | TimeType |
static const PointerSizeInt | cpu_speed_ |
POSIX API returns CPU ticks, so we need to divide by CPU speed. More... | |
TimeDiff_ | accumulated_times_ |
TimeDiff_ | last_start_ |
point in time of last start() More... | |
bool | is_running_ = false |
state of stop watch, either true(on) or false(off) More... | |
bool | isRunning () const |
bool | operator== (const StopWatch &stop_watch) const |
bool | operator!= (const StopWatch &stop_watch) const |
bool | operator< (const StopWatch &stop_watch) const |
bool | operator<= (const StopWatch &stop_watch) const |
bool | operator>= (const StopWatch &stop_watch) const |
bool | operator> (const StopWatch &stop_watch) const |
String | toString () const |
get a compact representation of the current time status. More... | |
static String | toString (const double time_in_seconds) |
TimeDiff_ | snapShot_ () const |
get the absolute times for current system, user and kernel times More... | |
This class is used to determine the current process' CPU (user and/or kernel) and wall time.
CPU time is measured as sum of all threads of the current process.
To read a time, the stopwatch must be started beforehand, but not necessarily stopped.
You can stop() the timer and resume() it later to omit intermediate steps which should not count towards the measured times.
|
private |
void clear | ( | ) |
Clear and stop the stop watch. This sets the stop watch to zero and stops it when running.
double getClockTime | ( | ) | const |
Get clock time. Return the accumulated wall clock (real) time in seconds.
Referenced by main(), and PeptideIndexing::run().
double getCPUTime | ( | ) | const |
Get CPU time. Return the accumulated CPU time in seconds. CPU time is the sum of user time and system time across all threads.
double getSystemTime | ( | ) | const |
Get user time. Return the accumulated system time in seconds across all threads.
double getUserTime | ( | ) | const |
Get user time. Return the accumulated user time in seconds across all threads.
bool isRunning | ( | ) | const |
Return true if the stop watch is running.
bool operator!= | ( | const StopWatch & | stop_watch | ) | const |
Inequality operator. Return false if two stop watches differ in any way, i.e. they differ in either the clock, user, or system time or have a different running status.
stop_watch | the stop watch to compare with |
bool operator< | ( | const StopWatch & | stop_watch | ) | const |
Lesser than operator. Return true, if the stop watch is in all timings lesser than the stop watch to be compared with (clock, user and system time).
stop_watch | the stop watch to compare with |
bool operator<= | ( | const StopWatch & | stop_watch | ) | const |
Lesser or equal operator. Return true, if the stop watch is in all timings lesser or equal than the stop watch to be compared with (clock, user and system time).
stop_watch | the stop watch to compare with |
bool operator== | ( | const StopWatch & | stop_watch | ) | const |
Equality operator. Return true if two stop watches are equal, i.e. they contain exactly the same time intervals for clock, user and system time and have the same running status.
stop_watch | the stop watch to compare with |
bool operator> | ( | const StopWatch & | stop_watch | ) | const |
Greater operator. Return true, if the stop watch is in all timings greater than the stop watch to be compared with (clock, user and system time).
stop_watch | the stop watch to compare with |
bool operator>= | ( | const StopWatch & | stop_watch | ) | const |
Greater or equal operator. Return true, if the stop watch is in all timings greater or equal than the stop watch to be compared with (clock, user and system time).
stop_watch | the stop watch to compare with |
void reset | ( | ) |
Clear the stop watch but keep running.
The stop watch is reset to 0, but not stopped (if running).
Referenced by PeptideIndexing::run().
void resume | ( | ) |
Resume a stopped StopWatch.
Exception::Precondition | if the StopWatch is already running |
|
private |
get the absolute times for current system, user and kernel times
void start | ( | ) |
Start the stop watch.
Starting, Stopping and Resetting the stop watch
If the watch holds data from previous measurements, these will be reset before starting up, i.e. it is not possible to resume by start(), stop(), start(). Use resume(), stop(), resume() instead.
Exception::Precondition | if the StopWatch is already running |
Referenced by main(), and PeptideIndexing::run().
void stop | ( | ) |
Stop the stop watch (can be resumed later). If the stop watch was not running an exception is thrown.
Exception::Precondition | if the StopWatch is not running |
Referenced by main(), and PeptideIndexing::run().
String toString | ( | ) | const |
get a compact representation of the current time status.
The output will be something like: 2.10 s (wall), 1.67 s (CPU), 0.12 s (system), 1.54 s (user)
Referenced by PeptideIndexing::run().
custom string formatting of time, using only the minimal number of units required (e.g., does not report hours when seconds suffice).
|
private |
currently accumulated times between start to stop intervals (initially 0), not counting the currently running interval which started at last_start_
|
staticprivate |
POSIX API returns CPU ticks, so we need to divide by CPU speed.
|
private |
state of stop watch, either true(on) or false(off)