Hello,
I am trying to develop my skills in c language.
Measuring the process time is very important to check the timings
of the internal signals.
As the first step, I made a program as follows:
-------------------------------------------------------------------
#include <stdio.h>
#include <time.h>
main()
{
int i;
clock_t start,end;
double elapsed;
start=clock();
for(i=0;i<=100000;i++){
printf("Test!\n");
}
end=clock();
elapsed=((double)(end-start))/CLOCKS_PER_SEC;
printf("Elapsed time = %.12lf[sec]\n",elapsed);
printf("In clock ticks : %lf\n",end-start);
printf("CLOCKS_PER_SEC = %d\n",CLOCKS_PER_SEC);
}
--------------------------------------------------------------------
.
When I executed this program, I got the following result:
--------------------------------------------------------------------
...
Test!
Test!
Test!
Elapsed time = 0.120000000000[sec]
In clock ticks : 0.120000
CLOCKS_PER_SEC = 1000000
--------------------------------------------------------------------
.
It's strange that I could count about 5 seconds until the final
"Test!" was appeared on the display...
I don't know why the elapsed time in second is equal to that in
clock ticks.
Could you guess what's wrong with it together?
(Linux version : 2.4.18-14 and gcc version : 3.2)
Snowet2000