clock()?

Hi all,

im trying to calculate how much time does my program run, use very simple script

clock_t end, start;
start= clock();
int i;
printf(“initial %d\n”,(int)start);

for(i=0;i<20;i++)
{
end=clock();
printf(“Time elapsed: %d\n”,(int)end);
}

but it outputs 0 all the time. cant figure out where could be the problem.

any ideas?

Nushki,

I think you will get the same result with gcc as with pgcc. I believe the
problem is that the clock() resolution is not very small, and the cpus are very fast.

Send mail to trs@pgroup.com, and I will send you dclock(), a routine that
counts the cpu cycles, and then converts the count to seconds. It is
better for measuring small amounts of time.

thanks,
dave