2 * This program can be used to calibrate the clock reading jitter of a
3 * particular CPU and operating system. It first tickles every element
4 * of an array, in order to force pages into memory, then repeatedly calls
5 * gettimeofday() and, finally, writes out the time values for later
6 * analysis. From this you can determine the jitter and if the clock ever
15 #include "ntp_types.h"
22 #define NBUF 100001 /* size of basic histogram */
23 #define NSRT 20000 /* size of overflow histogram */
24 #define NCNT (600 * 1000000) /* sample interval (us) */
26 extern int col(hrtime_t *, hrtime_t *);
27 extern hrtime_t gethrtime(void);
36 hrtime_t t, u, v, w, gtod[NBUF], ovfl[NSRT];
39 * Force pages into memory
41 for (i = 0; i < NBUF; i++)
43 for (i = 0; i < NSRT; i++)
59 printf("error <= 0 %ld %d %d, %d %d\n", w, ts.tv_sec,
60 ts.tv_usec, tr.tv_sec, tr.tv_usec);
62 } else if (w > NBUF - 1) {
75 for (i = 0; i < NBUF - 1; i++) {
77 printf("%ld %ld\n", i, gtod[i]);
81 qsort((char *)ovfl, (size_t)n, sizeof(hrtime_t), col);
84 for (i = 0; i < n; i++) {
87 printf("%ld %ld\n", w, j);
94 printf("%ld %ld\n", w, j);