title: What is the true getrusage resolution?
body: <p>I'm trying to measure <a href="https://man7.org/linux/man-pages/man2/getrusage.2.html" rel="nofollow noreferrer">getrusage</a> resolution via simple program:</p>
  <pre><code>#include &lt;cstdio&gt;
  #include &lt;sys/time.h&gt;
  #include &lt;sys/resource.h&gt;
  #include &lt;cassert&gt;
  
  int main(int argc, const char *argv[]) {
      struct rusage u = {0};
      assert(!getrusage(RUSAGE_SELF, &amp;u));
      size_t  cnt = 0;
      while(true) {
          ++cnt;
          struct rusage uz = {0};
          assert(!getrusage(RUSAGE_SELF, &amp;uz));
          if(u.ru_utime.tv_sec != uz.ru_utime.tv_sec || u.ru_utime.tv_usec != uz.ru_utime.tv_usec) {
              std::printf(&quot;u:%ld.%06ld\tuz:%ld.%06ld\tcnt:%ld\n&quot;, 
                      u.ru_utime.tv_sec, u.ru_utime.tv_usec,
                      uz.ru_utime.tv_sec, uz.ru_utime.tv_usec,
                      cnt);
              break;
          }
      }
  }
  </code></pre>
  <p>And when I run it, I usually get output similar to the following:</p>
  <pre>
  ema@scv:~/tmp/getrusage$ ./gt
  u:0.000562  uz:0.000563 cnt:1
  ema@scv:~/tmp/getrusage$ ./gt
  u:0.000553  uz:0.000554 cnt:1
  ema@scv:~/tmp/getrusage$ ./gt
  u:0.000496  uz:0.000497 cnt:1
  ema@scv:~/tmp/getrusage$ ./gt
  u:0.000475  uz:0.000476 cnt:1
  </pre>
  <p>Which seems to hint that the resolution of <em>getrusage</em> is around 1 microsecond.
  I thought it should be around 1 / <code>getconf CLK_TCK</code> (i.e. 100hz, hence 10 millisecond).</p>
  <p>What is the true getrusage resolution?<br>
  Am I doing anything wrong?</p>
  <p>Ps. Running this on Ubuntu 20.04, <code>Linux scv 5.13.0-52-generic #59~20.04.1-Ubuntu SMP Thu Jun 16 21:21:28 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux</code>, 5950x.</p>