#include #include #include #include int main( int a, char ** b) { time_t tick; struct timeval tv[2]; int prev = 0; 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 = 1; tv[1] = tv[0]; } }