How to measure inserting time in seconds?
I tried to use:
struct timeval t1,t2;
I checked time before inserting input:
gettimeofday(&t1,NULL);
and the same after getting the input:
gettimeofday(&t2,NULL);
double elapsedTime=(t2.tv_sec - t1.tv_sec)*10000.0;
but It's not accurate at all !!
I need better way to measure seconds in Inserting time , and to know the differences in seconds in inserting each character.
// trying to insert 5 chars
for(i=0; i<=4 ; i++)
{
gettimeofday(&t1,NULL); //get time before getting char
c=getchar();
gettimeofday(&t2,NULL); //get time after geting char
elapsedTime=(t1.tv_sec - t2.tv_sec)*10000.0;
printf("\n char number %d his elapsed time =%d\n",i,elapsedTime);
}
I need to know the seconds rates, on inserting "clicking" chars as input , and to calculate elapsedTime
in seconds :
output should be like:
time between inserting first character and the second is : 0.002 seconds
time between..........second character and the third is: 1.008 seconds