arbb::scoped_timer_impl< source_t, stamp_t, value_t > Class Template Reference

A scoped_timer measures the time elapsed during its lifetime, and stores this time in a variable passed in during its constructor. More...

List of all members.

Public Types

enum  unit_type { unit_us, unit_ms, unit_s }
 

Time unit, e.g. milliseconds.

More...
typedef value_t value_type
typedef source_t source_type
typedef stamp_t stamp_type

Public Member Functions

template<typename time_value_t >
 scoped_timer_impl (time_value_t &time_value, unit_type unit=unit_ms)
 Begin measuring a duration, which will be stored in the given time variable using the provided unit (milliseconds by default).
template<typename time_value_t >
 scoped_timer_impl (time_value_t &time_value, bool precondition, unit_type unit=unit_ms)
 Begin measuring a duration, but only if the provided precondition is met.
 ~scoped_timer_impl ()
 If the preconditions of this timer were met, or no preconditions were specified, measure the lifetime of this object and store it in the provided destination value.
bool precondition () const
 Get the precondition determining whether the duration is reported or not.
unit_type unit () const
 Get the time unit used to report the measured duration.
stamp_type stamp () const
 Get the time stamp marking the begin of the measured duration.

Detailed Description

template<typename source_t, typename stamp_t = typename source_t::stamp_type, typename value_t = typename source_t::value_type>
class arbb::scoped_timer_impl< source_t, stamp_t, value_t >

A scoped_timer measures the time elapsed during its lifetime, and stores this time in a variable passed in during its constructor.

The timer follows a policy-based design similar to type traits to factor out the actual time source used to measure a duration.

Template Parameters:

source_t Generate a time stamp, and calculate the time value.
stamp_t Type of a time stamp which is source_t::stamp_type by default.
value_t Type of a time value which is source_t::value_type by default.

Definition at line 37 of file scoped_timer.hpp.


Member Typedef Documentation

template<typename source_t , typename stamp_t = typename source_t::stamp_type, typename value_t = typename source_t::value_type>
typedef value_t arbb::scoped_timer_impl< source_t, stamp_t, value_t >::value_type

Definition at line 39 of file scoped_timer.hpp.

template<typename source_t , typename stamp_t = typename source_t::stamp_type, typename value_t = typename source_t::value_type>
typedef source_t arbb::scoped_timer_impl< source_t, stamp_t, value_t >::source_type

Definition at line 40 of file scoped_timer.hpp.

template<typename source_t , typename stamp_t = typename source_t::stamp_type, typename value_t = typename source_t::value_type>
typedef stamp_t arbb::scoped_timer_impl< source_t, stamp_t, value_t >::stamp_type

Definition at line 41 of file scoped_timer.hpp.


Member Enumeration Documentation

template<typename source_t , typename stamp_t = typename source_t::stamp_type, typename value_t = typename source_t::value_type>
enum arbb::scoped_timer_impl::unit_type

Time unit, e.g. milliseconds.

Enumerator:
unit_us 

Time measured in microseconds.

unit_ms 

Time measured in milliseconds.

unit_s 

Time measured in seconds.

Definition at line 44 of file scoped_timer.hpp.


Constructor & Destructor Documentation

template<typename source_t , typename stamp_t = typename source_t::stamp_type, typename value_t = typename source_t::value_type>
template<typename time_value_t >
arbb::scoped_timer_impl< source_t, stamp_t, value_t >::scoped_timer_impl ( time_value_t &  time_value,
unit_type  unit = unit_ms 
) [inline, explicit]

Begin measuring a duration, which will be stored in the given time variable using the provided unit (milliseconds by default).

This constructor also calls arbb::finish() to synchronize any pending operations.

Parameters:

time_value Records the measured time.
unit Time unit used to report the measurement.
template<typename source_t , typename stamp_t = typename source_t::stamp_type, typename value_t = typename source_t::value_type>
template<typename time_value_t >
arbb::scoped_timer_impl< source_t, stamp_t, value_t >::scoped_timer_impl ( time_value_t &  time_value,
bool  precondition,
unit_type  unit = unit_ms 
) [inline]

Begin measuring a duration, but only if the provided precondition is met.

If the precondition is true, the duration will be stored in the provided value once this timer destructs, using the provided unit (milliseconds by default). If the precondition is false, the timer will have no effect, and the provided value will remain unchanged. This constructor is useful, for example, when skipping the first few iterations of a timing loop. This constructor also calls arbb::finish() to synchronize any pending operations.

Parameters:

time_value Records the measured time.
precondition Set the precondition determining whether the duration is reported or not.
unit Time unit used to report the measurement.
template<typename source_t , typename stamp_t = typename source_t::stamp_type, typename value_t = typename source_t::value_type>
arbb::scoped_timer_impl< source_t, stamp_t, value_t >::~scoped_timer_impl (  ) 

If the preconditions of this timer were met, or no preconditions were specified, measure the lifetime of this object and store it in the provided destination value.

This destructor also calls arbb::finish() to synchronize any pending operations.


Member Function Documentation

template<typename source_t , typename stamp_t = typename source_t::stamp_type, typename value_t = typename source_t::value_type>
bool arbb::scoped_timer_impl< source_t, stamp_t, value_t >::precondition (  )  const

Get the precondition determining whether the duration is reported or not.

template<typename source_t , typename stamp_t = typename source_t::stamp_type, typename value_t = typename source_t::value_type>
unit_type arbb::scoped_timer_impl< source_t, stamp_t, value_t >::unit (  )  const

Get the time unit used to report the measured duration.

template<typename source_t , typename stamp_t = typename source_t::stamp_type, typename value_t = typename source_t::value_type>
stamp_type arbb::scoped_timer_impl< source_t, stamp_t, value_t >::stamp (  )  const

Get the time stamp marking the begin of the measured duration.


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

Submit feedback on this help topic

Copyright © 2010, Intel Corporation. All rights reserved.