STXXL  1.4-dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
stxxl::timer Class Reference

Detailed Description

Class timer is a simple stop watch timer.

It uses the timestamp() function to get the current time when start() is called. Then, after some processing, the function stop() functions can be called, or seconds() and other accessors can be called directly.

Examples:
examples/containers/copy_file.cpp, and examples/containers/sorter2.cpp.

Definition at line 70 of file timer.h.

Public Member Functions

 timer (bool start_immediately=false)
 initialize and optionally immediately start the timer More...
 
double mseconds () const
 return currently accumulated time in milliseconds More...
 
timeroperator+= (const timer &tm)
 accumulate elapsed time from another timer More...
 
void reset ()
 return accumulated time More...
 
double seconds () const
 return currently accumulated time in seconds (as double) More...
 
void start ()
 start timer More...
 
void stop ()
 stop timer More...
 
double useconds () const
 return currently accumulated time in microseconds More...
 

Static Public Attributes

static const bool is_real = true
 boolean indicating that this class does real timing More...
 

Static Private Member Functions

static double timestamp ()
 return current timestamp More...
 

Private Attributes

double accumulated
 total accumulated time in seconds. More...
 
double last_clock
 last start time of the stopwatch More...
 
bool running
 boolean whether the stopwatch timer is currently running More...
 

Friends

std::ostream & operator<< (std::ostream &os, const timer &t)
 direct <<-operator for ostream. Can be used for printing with std::cout. More...
 

Constructor & Destructor Documentation

stxxl::timer::timer ( bool  start_immediately = false)
inline

initialize and optionally immediately start the timer

Definition at line 92 of file timer.h.

Member Function Documentation

double stxxl::timer::mseconds ( ) const
inline

return currently accumulated time in milliseconds

Examples:
examples/containers/sorter2.cpp.

Definition at line 120 of file timer.h.

References stxxl::timestamp().

timer& stxxl::timer::operator+= ( const timer tm)
inline

accumulate elapsed time from another timer

Definition at line 147 of file timer.h.

References seconds().

void stxxl::timer::reset ( )
inline

return accumulated time

Definition at line 113 of file timer.h.

References stxxl::timestamp().

double stxxl::timer::seconds ( ) const
inline

return currently accumulated time in seconds (as double)

Examples:
examples/containers/copy_file.cpp.

Definition at line 138 of file timer.h.

References stxxl::timestamp().

Referenced by operator+=().

void stxxl::timer::start ( )
inline

start timer

Examples:
examples/containers/sorter2.cpp.

Definition at line 99 of file timer.h.

References stxxl::timestamp().

void stxxl::timer::stop ( )
inline

stop timer

Examples:
examples/containers/sorter2.cpp.

Definition at line 106 of file timer.h.

References stxxl::timestamp().

static double stxxl::timer::timestamp ( )
inlinestaticprivate

return current timestamp

Definition at line 82 of file timer.h.

References stxxl::timestamp().

double stxxl::timer::useconds ( ) const
inline

return currently accumulated time in microseconds

Definition at line 129 of file timer.h.

References stxxl::timestamp().

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const timer t 
)
friend

direct <<-operator for ostream. Can be used for printing with std::cout.

Definition at line 157 of file timer.h.

Member Data Documentation

double stxxl::timer::accumulated
private

total accumulated time in seconds.

Definition at line 76 of file timer.h.

const bool stxxl::timer::is_real = true
static

boolean indicating that this class does real timing

Definition at line 89 of file timer.h.

double stxxl::timer::last_clock
private

last start time of the stopwatch

Definition at line 79 of file timer.h.

bool stxxl::timer::running
private

boolean whether the stopwatch timer is currently running

Definition at line 73 of file timer.h.


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