* This program can be used to calibrate the clock reading jitter of a
* particular CPU and operating system. It first tickles every element
* of an array, in order to force pages into memory, then repeatedly calls
* gettimeofday() and, finally, writes out the time values for later
* analysis. From this you can determine the jitter and if the clock ever
struct timeval tp
, ts
, tr
;
long temp
, j
, i
, gtod
[NBUF
];
* Force pages into memory
for (i
= 0; i
< NBUF
; i
++)
for (i
= 0; i
< NBUF
; i
++) {
tr
.tv_usec
-= ts
.tv_usec
;
gtod
[i
] = tr
.tv_sec
* 1000000 + tr
.tv_usec
;
* Write out gtod array for later processing with S
for (i
= 0; i
< NBUF
- 1; i
++) {
printf("%lu\n", gtod[i]);
gtod
[i
] = gtod
[i
+ 1] - gtod
[i
];
printf("%lu\n", gtod
[i
]);
* Sort the gtod array and display deciles
for (i
= 0; i
< NBUF
- 1; i
++) {
for (j
= 0; j
<= i
; j
++) {
fprintf(stderr
, "First rank\n");
fprintf(stderr
, "%10ld%10ld\n", i
, gtod
[i
]);
fprintf(stderr
, "Last rank\n");
for (i
= NBUF
- 11; i
< NBUF
- 1; i
++)
fprintf(stderr
, "%10ld%10ld\n", i
, gtod
[i
]);