#include <stdio.h>
#include <time.h>
#include <sys/time.h>

int main(int argc, char **argv)
{
	long thistime, lasttime = 0;
	int nbogus = 0;
	int ndistinct = 0;
	int i;

	for (i=0; i<1000000000; i++)
	{
#if 1
		struct timespec tv;
		clock_gettime(CLOCK_REALTIME, &tv);
		thistime = (long) tv.tv_sec * 1000000000 + tv.tv_nsec;
#else
		struct timeval tv;
		gettimeofday(&tv, NULL);
		thistime = (long) tv.tv_sec * 1000000 + tv.tv_usec;
#endif

		if (thistime < lasttime)
			nbogus++;
		else if (thistime > lasttime)
			ndistinct++;
		lasttime = thistime;
	}

	printf("%d bogus readings\n", nbogus);
	printf("%d distinct readings\n", ndistinct);

	return 0;
}
