title: Just how precise is query_performance_counter in c++
body: <p>So I have been doodling around with the _Query_perf_counter() in MVS 2017
  and I have found that is extremely accurate, the results always match with the ones you'd get when using std::chrono::highresolution_clock
  The difference is, the chrono clock ends at the unit &quot;nanosecond&quot; which is an incredibly short amount of time, and doubtly hard to measure but apparently still possible.
  Now the query performance counter works along these lines</p>
  <pre><code>unsigned long long start = _Query_perf_counter();
  doStuff();
  unsigned long long end = _Query_perf_counter();
  time needed = (end - start) * x / _Query_perf_frequency();
  </code></pre>
  <p>where x is any power of 1000 regarding what unit of time you want.
  1,000 for milliseconds, 1,000,000 for microseconds and so on and so forth.
  Now measuring things in nanoseconds gives you this result</p>
  <p><a href="https://i.stack.imgur.com/fS5bz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fS5bz.png" alt="enter image description here" /></a></p>
  <p>QPF  being query performance counter and HRC being high-resolution clock</p>
  <p>now you can push this to nanoseconds with both these things:</p>
  <p><a href="https://i.stack.imgur.com/jCXPS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jCXPS.png" alt="enter image description here" /></a></p>
  <p>of course, HRC takes a little longer as it is evaluated just after the QPF.
  at this point, you cannot measure things any more accurately with the HRC, as you can see it returns an integer and any smaller unit than nanoseconds won't work. though you can push the QPF even further, how much further you ask?
  Well you see those 6 post decimal point digits? this much, and more!
  A total of x= 10^18, which is the equivalent of a measurement in <strong>attoseconds</strong></p>
  <p>I'm wondering now, just how accurate is this?
  Measuring things in attoseconds is physically obviously not possible, the shortest ever measured time, according to a quick google search is somewhere around 20 attoseconds, which could technically be broken with this. So why is that?</p>
  <p>Thanks in advance
  Folling</p>