title: getrusage returns rounded numbers
body: <p>I am trying to measure the resource usage time (user and system) for various function calls using rusage.
  I find that the results I am getting are in the order of 10s of milliseconds like 0s 70000us, 10000us etc. Please let me know if there is a way to set precision/ granularity for getrusage.</p>
  
  <p>My program is simple:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;string.h&gt;
  #include&lt;stdlib.h&gt;
  #include &lt;sys/time.h&gt;
  #include &lt;sys/resource.h&gt;
  #include &lt;unistd.h&gt;
  
  int main(){
    struct rusage usage;
    struct timeval start, end;
    int i, j, k = 0;
  
    getrusage(RUSAGE_SELF, &amp;usage);
    start = usage.ru_utime;
    printf("buffer check\n");
    char *str = "---";
    int arr[100],ctr;
  
    for(ctr = 0;ctr&lt;100;ctr++){
  
      arr[ctr] = ctr + 1000;
  
    }
  
    for (i = 0; i &lt; 10000; i++) {
       for (j = 0; j &lt; 10000; j++) {
        k += 20;
    }
   }
  
   getrusage(RUSAGE_SELF, &amp;usage);
   end = usage.ru_utime;
  
   printf("Started at: %ld.%lds\n", start.tv_sec, start.tv_usec);
   printf("Ended at: %ld.%lds\n", end.tv_sec, end.tv_usec);
  
   return 1;
  }
  </code></pre>
  
  <p>Result
  Started at: 0.0s
  Ended at: 0.2000000s</p>
  
  <p>I added another for loop and got result like:
  Started at: 0.0s
  Ended at: 0.7000000s
  I browsed a lot to find a possible way to get accurate timings. Came across 3 parameter getrusage in linux sources etc. but I am not sure how to use it since it required the task pointer as the first param. One of the link suggested it has got to do with linux version. Regardless, please let me know if there is any way to set the precision/granularity. If not, let me know if there is any alternative to getrusage. gettimeofDay does not seem to give the resource usage details so looking for actual implementation of getrusage if somehow I am not able to set precision.</p>