-#ifdef DEBUG_TIMING
-
-static void
-check_timing (unsigned long delay)
-{
- static unsigned long frame_count = 0;
- static unsigned long delay_sum = 0;
- static struct timeval prev1 = { 0, };
- static struct timeval prev2 = { 0, };
- struct timeval now;
- double uprev1, uprev2, unow;
-
-# ifdef GETTIMEOFDAY_TWO_ARGS
- gettimeofday (&now, 0);
-# else
- gettimeofday (&now);
-# endif
-
- if (prev1.tv_sec == 0)
- prev1 = prev2 = now;
-
- frame_count++;
-
- uprev1 = prev1.tv_sec + ((double) prev1.tv_usec * 0.000001);
- uprev2 = prev2.tv_sec + ((double) prev2.tv_usec * 0.000001);
- unow = now.tv_sec + ((double) now.tv_usec * 0.000001);
-
- if (unow >= uprev1 + 1.5)
- fprintf (stderr,
- "%s: warning: blocked event processing for %.1f secs!\n",
- progname, unow - uprev1);
- prev1 = now;
-
- if (unow >= uprev2 + 10.0)
- {
- double fps = frame_count / (unow - uprev2);
- double elapsed = unow - uprev2;
- double slept = (delay_sum * 0.000001);
- double sleep_ratio = slept / elapsed;
-
- if (sleep_ratio < 0.10) {
- fprintf (stderr,
- "%s: warning: only %.0f%% idle over the"
- " last %2.0f secs (at %.1f FPS)\n",
- progname, 100 * sleep_ratio, elapsed, fps);
- }
-
- prev2 = now;
- frame_count = 0;
- delay_sum = 0;
- }
-
- delay_sum += delay;
-}
-
-#else /* !DEBUG_TIMING */
-# define check_timing(delay) /**/
-#endif /* !DEBUG_TIMING */
-