1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Class timer</title> 5<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="../../../index.html" title="Chapter 1. Boost.Log v2"> 8<link rel="up" href="../../../attributes.html#header.boost.log.attributes.timer_hpp" title="Header <boost/log/attributes/timer.hpp>"> 9<link rel="prev" href="utc_time_traits.html" title="Struct utc_time_traits"> 10<link rel="next" href="../extract_idm46079579055520.html" title="Function template extract"> 11</head> 12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 13<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td></tr></table> 14<hr> 15<div class="spirit-nav"> 16<a accesskey="p" href="utc_time_traits.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../attributes.html#header.boost.log.attributes.timer_hpp"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../extract_idm46079579055520.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> 17</div> 18<div class="refentry"> 19<a name="boost.log.attributes.timer"></a><div class="titlepage"></div> 20<div class="refnamediv"> 21<h2><span class="refentrytitle">Class timer</span></h2> 22<p>boost::log::attributes::timer — A class of an attribute that makes an attribute value of the time interval since construction. </p> 23</div> 24<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2> 25<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: <<a class="link" href="../../../attributes.html#header.boost.log.attributes.timer_hpp" title="Header <boost/log/attributes/timer.hpp>">boost/log/attributes/timer.hpp</a>> 26 27</span> 28<span class="keyword">class</span> <a class="link" href="timer.html" title="Class timer">timer</a> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">attribute</span> <span class="special">{</span> 29<span class="keyword">public</span><span class="special">:</span> 30 <span class="comment">// types</span> 31 <span class="keyword">typedef</span> <span class="identifier">utc_time_traits</span><span class="special">::</span><span class="identifier">time_type</span><span class="special">::</span><span class="identifier">time_duration_type</span> <a name="boost.log.attributes.timer.value_type"></a><span class="identifier">value_type</span><span class="special">;</span> <span class="comment">// Attribute value type. </span> 32 33 <span class="comment">// <a class="link" href="timer.html#boost.log.attributes.timerconstruct-copy-destruct">construct/copy/destruct</a></span> 34 <a class="link" href="timer.html#idm46079579062560-bb"><span class="identifier">timer</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span> 35 <span class="keyword">explicit</span> <a class="link" href="timer.html#idm46079579061840-bb"><span class="identifier">timer</span></a><span class="special">(</span><a class="link" href="cast_source.html" title="Class cast_source">cast_source</a> <span class="keyword">const</span> <span class="special">&</span><span class="special">)</span><span class="special">;</span> 36<span class="special">}</span><span class="special">;</span></pre></div> 37<div class="refsect1"> 38<a name="idm44984881230496"></a><h2>Description</h2> 39<p>The timer attribute calculates the time passed since its construction and returns it on value acquisition. The attribute value type is <code class="computeroutput">boost::posix_time::time_duration</code>.</p> 40<p>On Windows platform there are two implementations of the attribute. The default one is more precise but a bit slower. This version uses <code class="computeroutput">QueryPerformanceFrequence</code>/<code class="computeroutput">QueryPerformanceCounter</code> API to calculate elapsed time.</p> 41<p>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:</p> 42<p><a href="http://support.microsoft.com/?scid=kb;en-us;895980" target="_top">http://support.microsoft.com/?scid=kb;en-us;895980</a> <a href="http://support.microsoft.com/?id=896256" target="_top">http://support.microsoft.com/?id=896256</a></p> 43<p>In case if none of these solutions apply, you are free to define <code class="computeroutput">BOOST_LOG_NO_QUERY_PERFORMANCE_COUNTER</code> macro to fall back to another implementation based on Boost.DateTime. </p> 44<div class="refsect2"> 45<a name="idm44984881224112"></a><h3> 46<a name="boost.log.attributes.timerconstruct-copy-destruct"></a><code class="computeroutput">timer</code> 47 public 48 construct/copy/destruct</h3> 49<div class="orderedlist"><ol class="orderedlist" type="1"> 50<li class="listitem"> 51<pre class="literallayout"><a name="idm46079579062560-bb"></a><span class="identifier">timer</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre> 52<p>Constructor. Starts time counting. </p> 53</li> 54<li class="listitem"> 55<pre class="literallayout"><span class="keyword">explicit</span> <a name="idm46079579061840-bb"></a><span class="identifier">timer</span><span class="special">(</span><a class="link" href="cast_source.html" title="Class cast_source">cast_source</a> <span class="keyword">const</span> <span class="special">&</span> source<span class="special">)</span><span class="special">;</span></pre> 56<p>Constructor for casting support </p> 57</li> 58</ol></div> 59</div> 60</div> 61</div> 62<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 63<td align="left"></td> 64<td align="right"><div class="copyright-footer">Copyright © 2007-2019 Andrey Semashev<p> 65 Distributed under the Boost Software License, Version 1.0. (See accompanying 66 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>). 67 </p> 68</div></td> 69</tr></table> 70<hr> 71<div class="spirit-nav"> 72<a accesskey="p" href="utc_time_traits.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../attributes.html#header.boost.log.attributes.timer_hpp"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../extract_idm46079579055520.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> 73</div> 74</body> 75</html> 76