title: Resolution of std::chrono::high_resolution_clock doesn't correspond to measurements
body: <p>Let me ask my question by this test program:</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;chrono&gt;
  
  using std::chrono::nanoseconds;
  using std::chrono::duration_cast;
  
  int main(int argc, char* argv[])
  {
      std::cout 
        &lt;&lt; &quot;Resolution (nano) = &quot; 
        &lt;&lt; (double) std::chrono::high_resolution_clock::period::num / 
                    std::chrono::high_resolution_clock::period::den * 
                    1000 * 1000 * 1000 
        &lt;&lt; std::endl;
  
      auto t1 = std::chrono::high_resolution_clock::now();
      std::cout &lt;&lt; &quot;How many nanoseconds does std::cout take?&quot; &lt;&lt; std::endl;
      auto t2 = std::chrono::high_resolution_clock::now();
  
      auto diff = t2-t1;
      nanoseconds ns = duration_cast&lt;nanoseconds&gt;(diff);
  
      std::cout &lt;&lt; &quot;std::cout takes &quot; &lt;&lt; ns.count() &lt;&lt; &quot; nanoseconds&quot; 
                &lt;&lt; std::endl;
      return 0;
  }
  </code></pre>
  <p>Output on my machine:</p>
  <blockquote>
  <p>Resolution (nano) = 100</p>
  <p>How many nanoseconds does std::cout take?</p>
  <p>std::cout takes 1000200 nanoseconds</p>
  </blockquote>
  <p>I receive either <code>1000200</code> or <code>1000300</code> or <code>1000400</code> or <code>1000500</code> or <code>1000600</code> or <code>2000600</code> as a result (= 1 or 2 microsecond). Obviously, either the resolution of <code>std::chrono</code> is <strong>not</strong> 100 nano-seconds <strong>or</strong> the way I measure the time of <code>std::cout</code> is wrong. (Why do I never receive something between 1 and 2 microseconds, for example <code>1500000</code>?)</p>
  <p>I need a high-resolution timer in C++. The OS itself provides a high-resolution timer, because I'm able to measure things with microsecond-precision using the C# <code>Stopwatch</code> class on the same machine. So I would just need to correctly use the high-resolution timer that the OS has!</p>
  <p>How do I fix my program to produce the expected results?</p>