Skip to content

Commit

Permalink
timer drift failures
Browse files Browse the repository at this point in the history
  • Loading branch information
robertdavidgraham committed Apr 21, 2019
1 parent e81b2e9 commit 174c3bd
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/pixie-timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ pixie_gettime(void)
#if defined(CLOCK_UPTIME_RAW)
/* macOS: ignores time when suspended/sleep */
x = clock_gettime(CLOCK_UPTIME_RAW, &tv);
#elif defined(CLOCK_MONOTONIC_RAW)
x = clock_gettime(CLOCK_MONOTONIC_RAW, &tv);
//#elif defined(CLOCK_MONOTONIC_RAW)
// x = clock_gettime(CLOCK_MONOTONIC_RAW, &tv);
#else
x = clock_gettime(CLOCK_MONOTONIC, &tv);
#endif
Expand Down Expand Up @@ -256,7 +256,7 @@ pixie_nanotime(void)

int pixie_time_selftest(void)
{
static const uint64_t duration = 123456;
static const uint64_t duration = 456789;
uint64_t start, stop, elapsed;


Expand All @@ -265,12 +265,14 @@ int pixie_time_selftest(void)
stop = pixie_gettime();
elapsed = stop - start;

if (elapsed < 0.9*duration || 1.1*duration < elapsed) {
/* I wonder how often this will fail just because the process
* gets swapped out, but I'm leaving it in to see if people notice */
if (elapsed < 0.9 * duration) {
fprintf(stderr, "timing error, long delay\n");
return 1;
}
if (1.2 * duration < elapsed) {
fprintf(stderr, "timing error, long delay %5.0f%%\n", elapsed*100.0/duration);
return 1;
}

return 0;
}

0 comments on commit 174c3bd

Please sign in to comment.