title: Negative duration with Boost Chrono's process_real_cpu_clock
body: <p>I am trying to use Boost.Chrono to measure CPU time of my code. My C++ code for this is given below. The problem is that I sometimes get negative durations as output. This happens when I use &quot;process_real_cpu_clock&quot;. When I use &quot;steady_clock&quot; the problem does not appear. Some of the outputs I  took are following:</p>
  <blockquote>
  <p>time for 1st implemention:360 ms</p>
  <p>time for 2nd implementation:-3284.97 ms</p>
  <hr />
  <p>time for 1st implemention:360 ms</p>
  <p>time for 2nd implementation:1010 ms</p>
  <hr />
  <p>time for 1st implemention:-3924.97 ms</p>
  <p>time for 2nd implementation:1010 ms</p>
  </blockquote>
  <p>Only the second one is as expected. I guess the problem was about overflow of the duration, but in the third output, time for 1st implementation should be around 1/3 of the time for 2nd implemenation, then there should not be overflow if I can see time for 2nd implemenation. (I am using Boost 1.54, and working with Ubuntu on VirtualBox)</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;ctime&gt;
  #include &lt;cstdlib&gt;
  #include &lt;boost/chrono.hpp&gt;
  #include &lt;boost/chrono/process_cpu_clocks.hpp&gt;
  
  int main() {
  
  int x,y,result,runs;
  srand(time(NULL));
  runs=1e7;
  
  
  boost::chrono::process_real_cpu_clock::time_point start, start2; 
  boost::chrono::process_real_cpu_clock::time_point end, end2;
  
  start= boost::chrono::process_real_cpu_clock::now();
  
      for (int i=0;i&lt;runs;i++) {
  
          x=rand() %100 +1;
          y=rand() %100 +1;
          auto dummy=x*y;
          result=(result+dummy)%50;
          } 
  end=boost::chrono::process_real_cpu_clock::now();
  boost::chrono::process_real_cpu_clock::duration diff=end-start;
  
  start2= boost::chrono::process_real_cpu_clock::now();
  
      for (int i=0;i&lt;(3*runs);i++) {
  
          x=rand() %100 +1;
          y=rand() %100 +1;
          auto dummy=x*y;
          result=(result+dummy)%50;
  
          } 
  end2=boost::chrono::process_real_cpu_clock::now();
  
  boost::chrono::process_real_cpu_clock::duration diff2=end2-start2;
  
       std::cout &lt;&lt; &quot;time for 1st implemention:&quot;&lt;&lt;boost::chrono::duration &lt;double, boost::milli&gt; (diff).count()&lt;&lt; &quot; ns&quot; &lt;&lt; std::endl;
       std::cout &lt;&lt; &quot;time for 2nd implementation:&quot;&lt;&lt;boost::chrono::duration &lt;double, boost::milli&gt; (diff2).count()&lt;&lt; &quot; ns&quot; &lt;&lt; std::endl;
  
  
  return 0;
  }
  </code></pre>