A scoped_timer measures the time elapsed during its lifetime, and stores this time in a variable passed in during its constructor. More...
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. |
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.
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.
typedef value_t arbb::scoped_timer_impl< source_t, stamp_t, value_t >::value_type |
Definition at line 39 of file scoped_timer.hpp.
typedef source_t arbb::scoped_timer_impl< source_t, stamp_t, value_t >::source_type |
Definition at line 40 of file scoped_timer.hpp.
typedef stamp_t arbb::scoped_timer_impl< source_t, stamp_t, value_t >::stamp_type |
Definition at line 41 of file scoped_timer.hpp.
enum arbb::scoped_timer_impl::unit_type |
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.
time_value | Records the measured time. | |
unit | Time unit used to report the measurement. |
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.
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. |
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.
bool arbb::scoped_timer_impl< source_t, stamp_t, value_t >::precondition | ( | ) | const |
Get the precondition determining whether the duration is reported or not.
unit_type arbb::scoped_timer_impl< source_t, stamp_t, value_t >::unit | ( | ) | const |
Get the time unit used to report the measured duration.
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.
Copyright © 2010, Intel Corporation. All rights reserved.