d.
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <iostream.h>
#include <stdio.h>
int
main( int, char ** )
{
time_t tick;
struct timeval tv[2];
bool prev = false;
int fwd = 0;
int back = 0;
int max = 0;
for ( ; ; ) {
gettimeofday( tv, 0 );
if (prev)
if (tv[0].tv_sec < tv[1].tv_sec ||
tv[0].tv_sec == tv[1].tv_sec && tv[0].tv_usec < tv[1].tv_usec){
unsigned long delta = ((tv[1].tv_sec - tv[0].tv_sec) * 1000000+
(tv[1].tv_usec - tv[0].tv_usec));
if (delta > max) max = delta;
++back;
} else
++fwd;
if (tick != tv[0].tv_sec && tv[0].tv_sec == tv[1].tv_sec + 1) {
tick = tv[0].tv_sec;
printf( "%.24s: fwd:%d/%d:back max %07lu\n",
ctime( &tv[0].tv_sec ), fwd, back, max );
fwd = back = 0;
max = 0;
}
prev = true;
tv[1] = tv[0];
}
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/