I am curious to know why does the function clock() only returns values in increments of 10,000 and is not able to return values in between.
I have the following code:
#include<iostream>
#include<time.h>
#include<stdio.h>
using namespace std;
int main()
{
int a;
clock_t clock_start;
time_t start1;
time(&start1);
clock_start = clock();
for(int i=0;i<200000;i++)
cout<<8;
time_t end1;
time(&end1);
clock_t clock_end = clock();
int b;
printf("\n\n%d",end1-start1);
printf("\nClock ticks ?? = %d",clock_end-clock_start);
return 0;
}
The result is either 0 or 10,000
There is no in-between.
The same situation is happening even if I modify the number of iterations the 'for' loop runs. The values are also multiple of 10,000
What is the reason behind this behavior and what is a practical use case for the "clock" function in this case? It seems quite unreliable to me.