<div class="gmail_quote">On Tue, May 22, 2012 at 9:41 PM, Vicente J. Botet Escriba <span dir="ltr">&lt;<a href="mailto:vicente.botet@wanadoo.fr" target="_blank">vicente.botet@wanadoo.fr</a>&gt;</span> wrote:<br><blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote">


  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    Le 22/05/12 18:55, Wilfried Kirschenmann a écrit :
    <div class="im"><blockquote type="cite">
      <div class="gmail_quote">Dear chrono maintainer team,<br>
        <br>
        Using the following example :<br>
        <br>
        int main(int argc, char **argv)<br>
        {<br>
               boost::chrono::process_real_cpu_clock::time_point start =
        boost::chrono::process_real_cpu_clock::now();<br>
        <br>
               for ( long i = 0; i &lt; 1000; ++i )  std::sqrt( 123.456L
        ); // burn some time<br>
               Sleep(10000); //idle some time<br>
        <br>
               boost::chrono::process_real_cpu_clock::time_point end =
        boost::chrono::process_real_cpu_clock::now();<br>
               std::cout &lt;&lt; end &lt;&lt; std::endl;<br>
        <br>
                boost::chrono::process_real_cpu_clock::duration elapsed
        = (end - start);<br>
               std::cout &lt;&lt; &quot;took real     : &quot; &lt;&lt; elapsed
         &lt;&lt; &quot;nanoseconds\n&quot;;<br>
        <br>
               return 0;<br>
        }<br>
        <br>
        I obtain negative times.<br>
        <br>
        I run boost 1.49 win32 on Windows 7 x64 with Visual studio 2010.<br>
        <br>
        Studying the behavior of the timer, I think that the error is
        one of these :<br>
        - process_real_cpu_clock::now() only stores the current time in
        a 32 bit integer instead of a 64 bit integer<br>
      </div>
    </blockquote>
    <br></div>
    I don&#39;t know from where are you getting this conclusion.
    process_real_cpu_clock is using boost::int_least64_t, as
    representation.<br>
    <br>
        typedef duration&lt;boost::int_least64_t, nano&gt;
    nanoseconds;    // at least 64 bits needed<br>
        class BOOST_CHRONO_DECL process_real_cpu_clock {<br>
        public:<br>
            typedef nanoseconds                          duration;<br>
            typedef duration::rep                        rep;<br>
            typedef duration::period                     period;<br>
            typedef chrono::time_point&lt;process_real_cpu_clock&gt;   
    time_point;<br>
            BOOST_STATIC_CONSTEXPR bool is_steady =             true;<br>
    <br>
            static BOOST_CHRONO_INLINE time_point now() BOOST_NOEXCEPT;<br>
    #if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING<br>
            static BOOST_CHRONO_INLINE time_point now(system::error_code
    &amp; ec );<br>
    #endif<div class="im"><br>
        };<br>
    <br>
    <br></div></div></blockquote><div>From the fact that it behaves as if there were a 32bit overflow. Which is in fact the case : <a href="https://svn.boost.org/trac/boost/ticket/6361">https://svn.boost.org/trac/boost/ticket/6361</a></div>

<div>The problem is fixed in 1.50 and I no longer get negative times.</div><div> </div><div>Wilfried K.</div><div> </div></div>

