OpenMS  2.5.0
List of all members
StopWatch Class Reference

StopWatch Class. More...

#include <OpenMS/SYSTEM/StopWatch.h>

Public Member Functions

Constructors and Destructors
 StopWatch ()
 
 StopWatch (const StopWatch &stop_watch)
 
virtual ~StopWatch ()
 
void clear ()
 
bool start ()
 
bool stop ()
 
void reset ()
 
Readout of the StopWatch
double getClockTime () const
 
double getUserTime () const
 
double getSystemTime () const
 
double getCPUTime () const
 
Assignment
StopWatchoperator= (const StopWatch &stop_watch)
 

Predicates

typedef clock_t TimeType
 
static PointerSizeInt cpu_speed_
 
bool is_running_
 
PointerSizeInt start_secs_
 
PointerSizeInt start_usecs_
 
TimeType start_user_time_
 
TimeType start_system_time_
 
PointerSizeInt current_secs_
 
PointerSizeInt current_usecs_
 
TimeType current_user_time_
 
TimeType current_system_time_
 
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)
 

Detailed Description

StopWatch Class.

This class is used to determine the current process time.

Member Typedef Documentation

◆ TimeType

typedef clock_t TimeType
private

Constructor & Destructor Documentation

◆ StopWatch() [1/2]

StopWatch ( )

Default constructor. Create a new stop watch. The stop watch is stopped.

◆ StopWatch() [2/2]

StopWatch ( const StopWatch stop_watch)

Copy constructor. Create a new stop watch from an existing stop watch.

◆ ~StopWatch()

virtual ~StopWatch ( )
virtual

Destructor. Destructs a stop watch object.

Member Function Documentation

◆ clear()

void clear ( )

Starting, Stopping and Resetting the stop watch Clear and stop the stop watch. This sets the stop watch to zero and stops it when running.

See also
reset

◆ getClockTime()

double getClockTime ( ) const

Get clock time. Return the accumulated clock (real) time in seconds.

Referenced by main(), and PeptideIndexing::run().

◆ getCPUTime()

double getCPUTime ( ) const

Get CPU time. Return the accumulated CPU time in seconds. CPU time is the sum of user time and system time.

◆ getSystemTime()

double getSystemTime ( ) const

Get user time. Return the accumulated system time in seconds.

◆ getUserTime()

double getUserTime ( ) const

Get user time. Return the accumulated user time in seconds.

◆ isRunning()

bool isRunning ( ) const

Return true if the stop watch is running.

Returns
bool true if the stop watch is running, false otherwise

◆ operator!=()

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.

Parameters
stop_watchthe stop watch to compare with
Returns
bool true on inequality, false otherwise

◆ operator<()

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).

Parameters
stop_watchthe stop watch to compare with
Returns
bool true if all times are lesser

◆ operator<=()

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).

Parameters
stop_watchthe stop watch to compare with
Returns
bool true if all times are lesser or equal

◆ operator=()

StopWatch& operator= ( const StopWatch stop_watch)

Assignment operator. Assigns a stop watch from another. The two stop watch will then run synchronously.

Returns
StopWatch *this

◆ operator==()

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.

Parameters
stop_watchthe stop watch to compare with
Returns
bool true on equality, false otherwise

◆ operator>()

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).

Parameters
stop_watchthe stop watch to compare with
Returns
bool true if all times are greater

◆ operator>=()

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).

Parameters
stop_watchthe stop watch to compare with
Returns
bool true if all times are greater or equal

◆ reset()

void reset ( )

Clear the stop watch without stopping. The stop watch is cleared, but not stopped (if running).

See also
clear

Referenced by PeptideIndexing::run().

◆ start()

bool start ( )

Start the stop watch. The stop watch is started. If the stop watch is already running, false is returned.

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().

Returns
bool false if the stop watch was already running, true otherwise

Referenced by main(), and PeptideIndexing::run().

◆ stop()

bool stop ( )

Stop the stop watch. The stop watch is stopped. If the stop watch was not running, false is returned.

Returns
bool false if the was not running, true otherwise

Referenced by main(), and PeptideIndexing::run().

◆ toString() [1/2]

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().

◆ toString() [2/2]

static String toString ( const double  time)
static

custom string formatting of time, using only the minimal number of units required (e.g., does not report hours when seconds suffice).

Member Data Documentation

◆ cpu_speed_

PointerSizeInt cpu_speed_
staticprivate

◆ current_secs_

PointerSizeInt current_secs_
private

◆ current_system_time_

TimeType current_system_time_
private

◆ current_usecs_

PointerSizeInt current_usecs_
private

◆ current_user_time_

TimeType current_user_time_
private

◆ is_running_

bool is_running_
private

◆ start_secs_

PointerSizeInt start_secs_
private

◆ start_system_time_

TimeType start_system_time_
private

◆ start_usecs_

PointerSizeInt start_usecs_
private

◆ start_user_time_

TimeType start_user_time_
private