Boost C++ Libraries: Ticket #680: significantly different timer class behaviour on Win and Lin https://svn.boost.org/trac10/ticket/680 <pre class="wiki">clock() function used in implementation of boost::timer behaves differently on Windows (MS XP Pro, MSVC 7.1) and Linux (FC3, gcc 3.4.2). Windows: clock measures elapsed time (wall clock). And this comply with boost::timer interface description. Example: boost::timer t; double sec = 1; ::Sleep(sec*1000); double d = t.elapsed(); assert(abs(d-sec) &lt; 0.1); Linux: clock() function returnes process CPU time. The above code will fail. This difference makes boost::timer a bad candidate for cross-platform development. I can propose alternative implementation with simalar right behaviour. ------------------------------------------ #ifndef _Timer_h_dlfkgh9384ytdflg9045uhy0823475mgd385uyn0v68uy c0n4c5 #define _Timer_h_dlfkgh9384ytdflg9045uhy0823475mgd385uyn0v68uy c0n4c5 #include &lt;time.h&gt; namespace Timer { /* Measures intervals of wall clock time, but not process CPU time. Resolution &amp; accuracy depends on time function abilities. */ class timer { public: // setup reference time point timer() { restart(); } // reset reference time point void restart() { ::time(&amp;m_ref_time); } // report difference between current time and reference point double elapsed() const { time_t curr_time; ::time(&amp;curr_time); double diff = difftime (curr_time, m_ref_time); return diff; } // forbidden private: timer(const timer &amp;); timer &amp; operator=(const timer &amp;); private: time_t m_ref_time; }; } // namespace Timer #endif //_Timer_h_dlfkgh9384ytdflg9045uhy0823475mgd385 uyn0v68uyc0n4c5 </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/680 Trac 1.4.3 nobody Tue, 11 Jul 2006 11:56:53 GMT <link>https://svn.boost.org/trac10/ticket/680#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/680#comment:1</guid> <description> <pre class="wiki">Logged In: NO A new boost::timer class is under development, it'll be using the boost::date_time classes for its timing. You can find current examples on Vault. Philippe Vaucher </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Marshall Clow</dc:creator> <pubDate>Wed, 11 Jul 2007 16:33:54 GMT</pubDate> <title>owner, status changed; severity set https://svn.boost.org/trac10/ticket/680#comment:2 https://svn.boost.org/trac10/ticket/680#comment:2 <ul> <li><strong>owner</strong> changed from <span class="trac-author">beman_dawes</span> to <span class="trac-author">Beman Dawes</span> </li> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">new</span> </li> <li><strong>severity</strong> → <span class="trac-field-new">Showstopper</span> </li> </ul> <p> assigning to actual user "bemandawes" instead of unknown user "beman_dawes" </p> Ticket Beman Dawes Tue, 28 Aug 2007 00:17:08 GMT status, resolution, description changed https://svn.boost.org/trac10/ticket/680#comment:3 https://svn.boost.org/trac10/ticket/680#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">duplicate</span> </li> <li><strong>description</strong> modified (<a href="/trac10/ticket/680?action=diff&amp;version=3">diff</a>) </li> </ul> <p> This request has been repeated many times. The Boost.System replacement that Philippe spoke of is now (27 Aut 2007) in the boost-sandbox. See boost-root/libs/system/doc/timer.html. </p> <p> This should be moving into the review queue in the next week or so. I'm closing out the ticket. </p> <p> Thanks, </p> <p> --Beman </p> Ticket