Skip to content

Instantly share code, notes, and snippets.

@nrdmn
Created September 13, 2019 12:46
Show Gist options
  • Save nrdmn/0f2d40d75b0711771d3a27e965ac73e8 to your computer and use it in GitHub Desktop.
Save nrdmn/0f2d40d75b0711771d3a27e965ac73e8 to your computer and use it in GitHub Desktop.
#include <sys/time.h>
#include <stddef.h>
#include <stdio.h>
#define THRESHOLD 1000
int main()
{
struct timeval a;
struct timeval b;
gettimeofday(&b, NULL);
for (;;) {
a = b;
gettimeofday(&b, NULL);
long long int diff = 100000*(b.tv_sec - a.tv_sec) + b.tv_usec - a.tv_usec;
if (diff > THRESHOLD) {
printf("time warped by %lld us\n", diff);
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment