...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::log::attributes::timer — A class of an attribute that makes an attribute value of the time interval since construction.
// In header: <boost/log/attributes/timer.hpp> class timer : public attribute { public: // types typedef utc_time_traits::time_type::time_duration_type value_type; // Attribute value type. // construct/copy/destruct timer(); explicit timer(cast_source const &); };
The timer attribute calculates the time passed since its construction and returns it on value acquisition. The attribute value type is boost::posix_time::time_duration
.
On Windows platform there are two implementations of the attribute. The default one is more precise but a bit slower. This version uses QueryPerformanceFrequence
/QueryPerformanceCounter
API to calculate elapsed time.
There are known problems with these functions when used with some CPUs, notably AMD Athlon with Cool'n'Quiet technology enabled. See the following links for more information and possible resolutions:
http://support.microsoft.com/?scid=kb;en-us;895980 http://support.microsoft.com/?id=896256
In case if none of these solutions apply, you are free to define BOOST_LOG_NO_QUERY_PERFORMANCE_COUNTER
macro to fall back to another implementation based on Boost.DateTime.
timer
public
construct/copy/destructtimer();
Constructor. Starts time counting.
explicit timer(cast_source const & source);
Constructor for casting support