rvm  1.11
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
timer Class Reference

Used as a stopwatch. More...

#include <timer.h>

Collaboration diagram for timer:
Collaboration graph

Public Types

typedef time_t value_type
 
typedef double duration_type
 

Public Member Functions

 timer ()
 C'tor. More...
 
 timer (const timer &a_timer)
 C'tor. More...
 
 timer (const value_type a_start)
 C'tor. More...
 
 timer (const value_type a_start, const value_type a_stop)
 C'tor. More...
 
void clear (void)
 Clear the timer. More...
 
void start (void)
 Start (or restart) the timer. More...
 
void stop (void)
 Stop the timer. More...
 
const value_type start_value (void) const
 Return the timer start value. More...
 
const value_type stop_value (void) const
 Return the timer stop value. More...
 
void assign (const timer &a_timer)
 Assign timer values from another timer instance. More...
 
void assign (const value_type a_start)
 Assign timer from a start value. More...
 
void assign (const value_type a_start, const value_type a_stop)
 Assign timer from start and stop values. More...
 
timeroperator= (const timer &a_timer)
 Assignment. More...
 
void use_localtime (const bool a_switch)
 Set whether to use localtime or GMT when constructing strings. More...
 
const bool use_localtime (void) const
 Return whether to use localtime or GMT. More...
 
const std::string started_at (void) const
 Generate a started-at string. More...
 
const std::string stopped_at (void) const
 Generate a stopped-at string. More...
 
const std::string duration (void) const
 Generate a duration string. More...
 
const std::string eta (unsigned int a_percent_complete) const
 Given a percent-complete for some unknown task, estimate a time to completion. More...
 
const std::string eta (unsigned int a_complete, unsigned int a_total) const
 Given a step number complete out of some total number of steps for some unknown task, estimate a time to completion. More...
 
const std::string bps (uint64 a_bytes) const
 Given a number of bytes, estimate the BPS. More...
 
const bool is_started (void) const
 Return whether or not the timer has been started. More...
 
const bool is_stopped (void) const
 Return whether or not the timer has been stopped. More...
 
const duration_type duration_secs (void) const
 Reutrn the duration in seconds. More...
 
const duration_type duration_mins (void) const
 Return the duration in minutes. More...
 
const duration_type duration_hours (void) const
 Return the duration in hours. More...
 
const duration_type duration_days (void) const
 Return the duration in days. More...
 
const duration_type duration_years (void) const
 Return the duration in years. More...
 

Private Member Functions

void mf_start_value (const value_type a_t)
 Set the timer start value. More...
 
void mf_stop_value (const value_type a_t)
 Set the timer stop value. More...
 
const duration_type mf_calculate_duration (const value_type a_start, const value_type a_stop) const
 Calculate the duration between start and stop. More...
 
const std::string mf_make_timer_string (const value_type a_t) const
 Generate a string in a regular human-readable format. More...
 
const std::string mf_make_string (const value_type a_t) const
 Generate a string in a timestamp format. More...
 
const std::string mf_make_string (const duration_type a_d) const
 Generate a duration string. More...
 

Private Attributes

value_type m_start
 
value_type m_stop
 
bool m_started
 
bool m_stopped
 
duration_type m_duration
 
bool m_use_localtime
 

Detailed Description

Used as a stopwatch.

Definition at line 29 of file timer.h.

Member Typedef Documentation

typedef double timer::duration_type

Definition at line 33 of file timer.h.

typedef time_t timer::value_type

Definition at line 32 of file timer.h.

Constructor & Destructor Documentation

timer::timer ( )

C'tor.

Definition at line 73 of file timer.cc.

References clear(), and start().

Here is the call graph for this function:

timer::timer ( const timer a_timer)

C'tor.

Definition at line 80 of file timer.cc.

References assign().

Here is the call graph for this function:

timer::timer ( const value_type  a_start)

C'tor.

Definition at line 86 of file timer.cc.

References assign().

Here is the call graph for this function:

timer::timer ( const value_type  a_start,
const value_type  a_stop 
)

C'tor.

Definition at line 92 of file timer.cc.

References assign().

Here is the call graph for this function:

Member Function Documentation

void timer::assign ( const timer a_timer)

Assign timer values from another timer instance.

Definition at line 162 of file timer.cc.

References clear(), is_started(), is_stopped(), m_duration, m_start, m_started, m_stop, m_stopped, mf_calculate_duration(), mf_start_value(), mf_stop_value(), start_value(), and stop_value().

Referenced by operator=(), test3(), and timer().

Here is the call graph for this function:

void timer::assign ( const value_type  a_start)

Assign timer from a start value.

Definition at line 174 of file timer.cc.

References clear(), and mf_start_value().

Here is the call graph for this function:

void timer::assign ( const value_type  a_start,
const value_type  a_stop 
)

Assign timer from start and stop values.

Definition at line 181 of file timer.cc.

References clear(), m_duration, m_start, m_stop, mf_calculate_duration(), mf_start_value(), and mf_stop_value().

Here is the call graph for this function:

const std::string timer::bps ( uint64  a_bytes) const

Given a number of bytes, estimate the BPS.

Definition at line 522 of file timer.cc.

References INTERNAL_ERROR, is_started(), is_stopped(), m_duration, throughput_to_string(), and TRY_nomem.

Here is the call graph for this function:

void timer::clear ( void  )

Clear the timer.

Definition at line 98 of file timer.cc.

References m_duration, m_start, m_started, m_stop, m_stopped, and m_use_localtime.

Referenced by assign(), job_path_report::clear(), report_manager::clear(), and timer().

const std::string timer::duration ( void  ) const
const timer::duration_type timer::duration_days ( void  ) const

Return the duration in days.

Definition at line 442 of file timer.cc.

References duration_hours().

Referenced by duration_years(), and test2().

Here is the call graph for this function:

const timer::duration_type timer::duration_hours ( void  ) const

Return the duration in hours.

Definition at line 432 of file timer.cc.

References duration_mins().

Referenced by duration_days(), and test2().

Here is the call graph for this function:

const timer::duration_type timer::duration_mins ( void  ) const

Return the duration in minutes.

Definition at line 422 of file timer.cc.

References duration_secs().

Referenced by duration_hours(), archive_manager::mf_log_status(), and test2().

Here is the call graph for this function:

const timer::duration_type timer::duration_secs ( void  ) const

Reutrn the duration in seconds.

Definition at line 411 of file timer.cc.

References INTERNAL_ERROR, is_started(), is_stopped(), and m_duration.

Referenced by duration_mins(), job_archiver::mf_process_rsync_io(), and test2().

Here is the call graph for this function:

const timer::duration_type timer::duration_years ( void  ) const

Return the duration in years.

Definition at line 452 of file timer.cc.

References duration_days().

Referenced by test2().

Here is the call graph for this function:

const std::string timer::eta ( unsigned int  a_percent_complete) const

Given a percent-complete for some unknown task, estimate a time to completion.

Definition at line 463 of file timer.cc.

References INTERNAL_ERROR, is_started(), is_stopped(), m_duration, mf_make_string(), TRY, TRY_nomem, and safe_num< T >::value().

Referenced by eta(), test(), and test3().

Here is the call graph for this function:

const std::string timer::eta ( unsigned int  a_complete,
unsigned int  a_total 
) const

Given a step number complete out of some total number of steps for some unknown task, estimate a time to completion.

Definition at line 493 of file timer.cc.

References eta(), INTERNAL_ERROR, is_started(), is_stopped(), TRY, and TRY_nomem.

Here is the call graph for this function:

const bool timer::is_started ( void  ) const

Return whether or not the timer has been started.

Definition at line 399 of file timer.cc.

References m_started.

Referenced by assign(), bps(), duration(), duration_secs(), eta(), archive_manager::mf_log_status(), started_at(), and stopped_at().

const bool timer::is_stopped ( void  ) const

Return whether or not the timer has been stopped.

Definition at line 405 of file timer.cc.

References m_stopped.

Referenced by assign(), bps(), duration(), duration_secs(), eta(), and stopped_at().

const timer::duration_type timer::mf_calculate_duration ( const value_type  a_start,
const value_type  a_stop 
) const
private

Calculate the duration between start and stop.

Definition at line 124 of file timer.cc.

References duration().

Referenced by assign(), and stop().

Here is the call graph for this function:

const std::string timer::mf_make_string ( const value_type  a_t) const
private

Generate a string in a timestamp format.

Definition at line 273 of file timer.cc.

References mf_make_timer_string(), and TRY_nomem.

Referenced by duration(), eta(), started_at(), and stopped_at().

Here is the call graph for this function:

const std::string timer::mf_make_string ( const duration_type  a_d) const
private

Generate a duration string.

Definition at line 283 of file timer.cc.

References estring::right, TRY, and TRY_nomem.

const std::string timer::mf_make_timer_string ( const value_type  a_t) const
private

Generate a string in a regular human-readable format.

Definition at line 212 of file timer.cc.

References ERROR, estring::fmt_str(), m_use_localtime, estring::right, TRY, and TRY_nomem.

Referenced by mf_make_string().

Here is the call graph for this function:

void timer::mf_start_value ( const value_type  a_t)
private

Set the timer start value.

Definition at line 109 of file timer.cc.

References m_start, and m_started.

Referenced by assign(), and start().

void timer::mf_stop_value ( const value_type  a_t)
private

Set the timer stop value.

Definition at line 116 of file timer.cc.

References m_stop, and m_stopped.

Referenced by assign(), and stop().

timer & timer::operator= ( const timer a_timer)

Assignment.

Definition at line 192 of file timer.cc.

References assign().

Here is the call graph for this function:

void timer::start ( void  )
const timer::value_type timer::start_value ( void  ) const

Return the timer start value.

Definition at line 150 of file timer.cc.

References m_start.

Referenced by assign(), test3(), and reportio::write_report().

const std::string timer::started_at ( void  ) const

Generate a started-at string.

Definition at line 359 of file timer.cc.

References INTERNAL_ERROR, is_started(), m_start, mf_make_string(), and TRY_nomem.

Referenced by report_manager::format_synopsis(), and test3().

Here is the call graph for this function:

void timer::stop ( void  )
const timer::value_type timer::stop_value ( void  ) const

Return the timer stop value.

Definition at line 156 of file timer.cc.

References m_stop.

Referenced by assign(), test3(), and reportio::write_report().

const std::string timer::stopped_at ( void  ) const

Generate a stopped-at string.

Definition at line 371 of file timer.cc.

References INTERNAL_ERROR, is_started(), is_stopped(), m_stop, mf_make_string(), and TRY_nomem.

Referenced by report_manager::format_synopsis(), and test3().

Here is the call graph for this function:

void timer::use_localtime ( const bool  a_switch)

Set whether to use localtime or GMT when constructing strings.

Definition at line 200 of file timer.cc.

References m_use_localtime.

Referenced by test3().

const bool timer::use_localtime ( void  ) const

Return whether to use localtime or GMT.

Definition at line 206 of file timer.cc.

References m_use_localtime.

Member Data Documentation

duration_type timer::m_duration
private

Definition at line 77 of file timer.h.

Referenced by assign(), bps(), clear(), duration(), duration_secs(), eta(), and stop().

value_type timer::m_start
private

Definition at line 73 of file timer.h.

Referenced by assign(), clear(), mf_start_value(), start_value(), started_at(), and stop().

bool timer::m_started
private

Definition at line 75 of file timer.h.

Referenced by assign(), clear(), is_started(), and mf_start_value().

value_type timer::m_stop
private

Definition at line 74 of file timer.h.

Referenced by assign(), clear(), mf_stop_value(), stop(), stop_value(), and stopped_at().

bool timer::m_stopped
private

Definition at line 76 of file timer.h.

Referenced by assign(), clear(), is_stopped(), and mf_stop_value().

bool timer::m_use_localtime
private

Definition at line 78 of file timer.h.

Referenced by clear(), mf_make_timer_string(), and use_localtime().


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