title: boost::thread_sleep vs boost::chrono::thread_clock inconsistent
body: <p>When I run this code</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;boost/thread.hpp&gt;
  #include &lt;boost/chrono/thread_clock.hpp&gt;
  
  void foo() {
      boost::this_thread::sleep(boost::posix_time::microseconds(500));
  }
  
  
  int main() {
      boost::chrono::thread_clock::time_point start = boost::chrono::thread_clock::now();    
      foo();   
      boost::chrono::thread_clock::time_point stop = boost::chrono::thread_clock::now();    
      std::cout &lt;&lt; "duration = " 
                &lt;&lt; boost::chrono::duration_cast&lt;boost::chrono::microseconds&gt;(stop-start).count() 
                &lt;&lt; " microsec\n";
  }
  </code></pre>
  
  <p>I get the following output:</p>
  
  <pre><code>duration = 121 microsec
  duration = 121 microsec
  duration = 110 microsec
  duration = 114 microsec
  </code></pre>
  
  <p>Also when I replace the <code>500</code> with a different value, eg <code>200</code>, the output is always around <code>100</code>. Compiling with <code>-O3</code>. Why is the timing not consistent?</p>
  
  <p>PS: I read that <code>sleep</code> is deprecated, but when I replace it with </p>
  
  <pre><code>boost::this_thread::sleep_for(boost::chrono::microseconds(200));
  </code></pre>
  
  <p>the output is in the range of ~20 microseconds.</p>