CAPD::DynSys Library  6.0.0
capd::auxil::timeused Class Reference

A class that stores the time at which it was initialized and then returns or displays the time used since the initialization. It displays this time when the destructor is invoked, e.g., at the end of program run. This class is used in most of the CHomP programs to measure the time used for the computations. More...

#include <capd/auxil/timeused.h>

Public Member Functions

 timeused (const char *msg=NULL)
 The default constructor. It may be given a message to be displayed when the destructor is called. More...
 
 timeused (std::ostream &out, const char *msg=NULL)
 
 ~timeused ()
 The destructor. More...
 
timeusedoperator= (std::ostream &out)
 Defines an output stream for displaying program's running time at program's termination. More...
 
timeusedoperator= (OutputStream &out)
 Defines an output stream for displaying program's running time at program's termination to a pair of streams. More...
 
timeusedoperator= (int n)
 Turns off writing program's running time at program's termination by assigning 0 to an object of this class. More...
 
timeusedoperator= (const char *msg)
 Changes the message displayed at program's termination. More...
 
timeusedreset ()
 Reset the timer to the current moment. More...
 
 operator double ()
 Returns the time from the initialization measured in seconds. More...
 
void show (std::ostream &out, const char *message=NULL) const
 Shows the time used from the beginning up to the current point. The time is preceded with the message (default: "Time used"). More...
 
void show (const char *message=NULL) const
 Shows the time used from the beginning up to the current point to the standard output stream. The time is preceded with the message (default: "Time used"). More...
 

Static Public Member Functions

static timeusedprogram_time ()
 

Protected Attributes

double cpu0
 CPU usage start time (in seconds). More...
 
std::time_t t0
 Start time (in seconds). More...
 
std::ostream * outstream1
 Output stream 1 (0 for no output). More...
 
std::ostream * outstream2
 Output stream 2 (0 for no output). More...
 
const char * message
 A message to display instead of "Used time" (if not 0). More...
 
int display
 Should the destructor display the time? Note: -1 makes the destructor display times only > 1 sec. More...
 

Friends

std::ostream & operator<< (std::ostream &out, const timeused &t)
 Shows the time elapsed up to this point. More...
 

Detailed Description

A class that stores the time at which it was initialized and then returns or displays the time used since the initialization. It displays this time when the destructor is invoked, e.g., at the end of program run. This class is used in most of the CHomP programs to measure the time used for the computations.

Constructor & Destructor Documentation

◆ timeused() [1/2]

capd::auxil::timeused::timeused ( const char *  msg = NULL)
inline

The default constructor. It may be given a message to be displayed when the destructor is called.

◆ timeused() [2/2]

capd::auxil::timeused::timeused ( std::ostream &  out,
const char *  msg = NULL 
)
inline

◆ ~timeused()

capd::auxil::timeused::~timeused ( )
inline

The destructor.

Member Function Documentation

◆ operator double()

capd::auxil::timeused::operator double ( )

Returns the time from the initialization measured in seconds.

◆ operator=() [1/4]

timeused & capd::auxil::timeused::operator= ( const char *  msg)
inline

Changes the message displayed at program's termination.

◆ operator=() [2/4]

timeused & capd::auxil::timeused::operator= ( int  n)
inline

Turns off writing program's running time at program's termination by assigning 0 to an object of this class.

◆ operator=() [3/4]

timeused & capd::auxil::timeused::operator= ( OutputStream out)
inline

Defines an output stream for displaying program's running time at program's termination to a pair of streams.

◆ operator=() [4/4]

timeused & capd::auxil::timeused::operator= ( std::ostream &  out)
inline

Defines an output stream for displaying program's running time at program's termination.

◆ program_time()

timeused & capd::auxil::timeused::program_time ( )
static

◆ reset()

timeused & capd::auxil::timeused::reset ( )

Reset the timer to the current moment.

◆ show() [1/2]

void capd::auxil::timeused::show ( const char *  message = NULL) const
inline

Shows the time used from the beginning up to the current point to the standard output stream. The time is preceded with the message (default: "Time used").

◆ show() [2/2]

void capd::auxil::timeused::show ( std::ostream &  out,
const char *  message = NULL 
) const
inline

Shows the time used from the beginning up to the current point. The time is preceded with the message (default: "Time used").

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const timeused t 
)
friend

Shows the time elapsed up to this point.

Member Data Documentation

◆ cpu0

double capd::auxil::timeused::cpu0
protected

CPU usage start time (in seconds).

◆ display

int capd::auxil::timeused::display
protected

Should the destructor display the time? Note: -1 makes the destructor display times only > 1 sec.

◆ message

const char* capd::auxil::timeused::message
protected

A message to display instead of "Used time" (if not 0).

◆ outstream1

std::ostream* capd::auxil::timeused::outstream1
protected

Output stream 1 (0 for no output).

◆ outstream2

std::ostream* capd::auxil::timeused::outstream2
protected

Output stream 2 (0 for no output).

◆ t0

std::time_t capd::auxil::timeused::t0
protected

Start time (in seconds).


The documentation for this class was generated from the following files: