title: C++: Timing in Linux (using clock()) is out of sync (due to OpenMP?)
body: <p>At the top and end of my program I use clock() to figure out how long my program takes to finish.  Unfortunately, it appears to take half as long as it's reporting.  I double checked this with the "time" command.</p>
  
  <p>My program reports:
  Completed in 45.86s</p>
  
  <p>Time command reports:
  real    0m22.837s
  user    0m45.735s
  sys     0m0.152s</p>
  
  <p>Using my cellphone to time it, it completed in 23s (aka: the "real" time).  "User" time is the sum of all threads, which would make sense since I'm using OpenMP.  (You can read about it here: <a href="https://stackoverflow.com/questions/556405/what-do-real-user-and-sys-mean-in-the-output-of-time1">What do &#39;real&#39;, &#39;user&#39; and &#39;sys&#39; mean in the output of time(1)?</a>)</p>
  
  <p>So, why is clock() reporting in "user" time rather than "real" time?  Is there a different function I should be using to calculate how long my program has been running?</p>
  
  <p>As a side note, Windows' clock() works as expected and reports in "real" time.</p>