summaryrefslogtreecommitdiff
path: root/mblock/src/lib/getres.cc
blob: c05ba792a5399b0bdfe4f8df7d746499df1e8338 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <time.h>
#include <stdio.h>

int
main(int argc, char **argv)
{
  bool ok = true;
  struct timespec ts;
  int r;

  r = clock_getres(CLOCK_REALTIME, &ts);
  if (r != 0){
    perror("clock_getres(CLOCK_REALTIME, ...)");
    ok = false;
  }
  else
    printf("clock_getres(CLOCK_REALTIME, ...)  => %11.9f\n",
	   (double) ts.tv_sec + ts.tv_nsec * 1e-9);


  r = clock_getres(CLOCK_MONOTONIC, &ts);
  if (r != 0){
    perror("clock_getres(CLOCK_MONOTONIC, ...");
    ok = false;
  }
  else
    printf("clock_getres(CLOCK_MONOTONIC, ...) => %11.9f\n",
	   (double) ts.tv_sec + ts.tv_nsec * 1e-9);


  return ok == true ? 0 : 1;
}