libmoost
moost::timer Class Reference

#include <timer.h>

List of all members.

Classes

class  scoped_time
 used for scoped access to timer More...

Public Types

typedef std::vector< std::pair
< int,
boost::posix_time::ptime > > 
threshold_times_type

Public Member Functions

 timer (size_t resolution=4096, int max_threshold_time_ms=(std::numeric_limits< int >::max)(), size_t threshold_resolution=128)
void time (const boost::posix_time::ptime &start)
 add a time to the timer
int min_time () const
 get the minimum time recorded
float avg_time () const
 get the average time recorded
void avg_stddev_time (float &avg, float &std_dev) const
 get the average time and standard deviation
int median_time () const
 get the median time
int max_time () const
 get the maximum time recorded
double count_per_second () const
 get the average number of times per second that times were recorded
size_t count () const
 get the count
int get_threshold_time () const
template<typename ForwardIterator >
void all_times (ForwardIterator out) const
 get all times
threshold_times_type past_threshold_times (int num) const
void reset ()
 reset timing statistics

Private Attributes

boost::mutex m_mutex
std::vector< int > m_times
std::vector< int >::iterator m_times_p
std::vector< int >::iterator m_times_end
int m_min_time
int m_max_time
size_t m_count
boost::posix_time::ptime m_start_time
int m_max_threshold_time_ms
threshold_times_type m_threshold_times
threshold_times_type::iterator m_threshold_times_p
threshold_times_type::iterator m_threshold_times_end

Detailed Description

timer collects statistics on how many times start()/stop() was called in a second, how many milliseconds elapsed on average between a start()/stop(), and best and worst times

Definition at line 42 of file timer.h.


Member Typedef Documentation

typedef std::vector< std::pair<int, boost::posix_time::ptime> > moost::timer::threshold_times_type

Definition at line 46 of file timer.h.


Constructor & Destructor Documentation

timer::timer ( size_t  resolution = 4096,
int  max_threshold_time_ms = (std::numeric_limits<int>::max)(),
size_t  threshold_resolution = 128 
)

Constructs a timer

Parameters:
resolutionhow many values to store for calculating the average

Definition at line 59 of file timer.cpp.

Here is the call graph for this function:


Member Function Documentation

template<typename ForwardIterator >
void moost::timer::all_times ( ForwardIterator  out) const [inline]

get all times

Definition at line 117 of file timer.h.

void timer::avg_stddev_time ( float &  avg,
float &  std_dev 
) const

get the average time and standard deviation

Definition at line 129 of file timer.cpp.

Here is the call graph for this function:

float timer::avg_time ( ) const

get the average time recorded

Definition at line 118 of file timer.cpp.

Here is the caller graph for this function:

size_t timer::count ( ) const

get the count

Definition at line 181 of file timer.cpp.

double timer::count_per_second ( ) const

get the average number of times per second that times were recorded

Definition at line 168 of file timer.cpp.

int moost::timer::get_threshold_time ( ) const [inline]

Definition at line 112 of file timer.h.

int timer::max_time ( ) const

get the maximum time recorded

Definition at line 162 of file timer.cpp.

int timer::median_time ( ) const

get the median time

Definition at line 148 of file timer.cpp.

int timer::min_time ( ) const

get the minimum time recorded

Definition at line 112 of file timer.cpp.

void timer::reset ( )

reset timing statistics

Definition at line 187 of file timer.cpp.

Here is the caller graph for this function:

void timer::time ( const boost::posix_time::ptime &  start)

add a time to the timer

Definition at line 72 of file timer.cpp.


Member Data Documentation

size_t moost::timer::m_count [private]

Definition at line 56 of file timer.h.

Definition at line 60 of file timer.h.

int moost::timer::m_max_time [private]

Definition at line 55 of file timer.h.

int moost::timer::m_min_time [private]

Definition at line 54 of file timer.h.

boost::mutex moost::timer::m_mutex [mutable, private]

Definition at line 50 of file timer.h.

boost::posix_time::ptime moost::timer::m_start_time [private]

Definition at line 58 of file timer.h.

Definition at line 63 of file timer.h.

threshold_times_type::iterator moost::timer::m_threshold_times_end [private]

Definition at line 65 of file timer.h.

threshold_times_type::iterator moost::timer::m_threshold_times_p [private]

Definition at line 64 of file timer.h.

std::vector<int> moost::timer::m_times [private]

Definition at line 51 of file timer.h.

std::vector<int>::iterator moost::timer::m_times_end [private]

Definition at line 53 of file timer.h.

std::vector<int>::iterator moost::timer::m_times_p [private]

Definition at line 52 of file timer.h.


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