(root)/
binutils-2.41/
gprofng/
testsuite/
lib/
smalltest.c
       1  #include <stdio.h>
       2  #include <time.h>
       3  
       4  typedef long long hrtime_t;
       5  
       6  hrtime_t
       7  gethrtime (void)
       8  {
       9    struct timespec tp;
      10    hrtime_t rc = 0;
      11  #ifdef CLOCK_MONOTONIC_RAW
      12    int r = clock_gettime (CLOCK_MONOTONIC_RAW, &tp);
      13  #else
      14    int r = clock_gettime (CLOCK_MONOTONIC, &tp);
      15  #endif
      16  
      17    if (r == 0)
      18      rc = ((hrtime_t) tp.tv_sec) * 1e9 + (hrtime_t) tp.tv_nsec;
      19    return rc;
      20  }
      21  
      22  volatile long x; /* temp variable for long calculation */
      23  
      24  int
      25  main (int argc, char **argv)
      26  {
      27    long long count = 0;
      28    hrtime_t start = gethrtime ();
      29  
      30    do
      31      {
      32        x = 0;
      33        for (int j = 0; j < 1000000; j++)
      34  	x = x + 1;
      35        count++;
      36      }
      37    while (start + 2e9 > gethrtime ());
      38    printf("count=%lld  x=%lld\n", count, x);
      39    return 0;
      40  }
      41