Hi,<br><br>I have an animation program that uses the clock() function<br>for synchronization. It works fine with MinGW 3.2, but not with gcc 4.1.2 (FC6).<br><br>In the later case, clock() always return 0. I saw some people pointing at the same problem
<br>in the past, but I thought it would have been fixed by now.<br><br>I managed to implement "getus", which seems to do what I need. Is this the right course?<br><br>Thanks. <br>__________________________________________________________________
<br><br>#include <sys/time.h><br>#include <time.h><br>#include <stdio.h><br><br>#define getus(tv) (tv.tv_sec*CLOCKS_PER_SEC + tv.tv_usec)<br>int main() {<br> clock_t ca,cb;<br> time_t wa,wb;<br> struct timeval tva, tvb;
<br> double c,w;<br> double d;<br> char s[10];<br> ca = clock();<br> wa = time(0);<br> gettimeofday(&tva, NULL);<br> printf("hit enter when ready ");<br> fflush (stdout);<br> gets(s);<br> cb = clock();
<br> wb = time(0);<br> gettimeofday(&tvb, NULL);<br> c = (double) (cb-ca);<br> w = (double) difftime(wb,wa);<br> c /= (double) CLOCKS_PER_SEC;<br> d = (getus(tvb) - getus(tva))/(double) CLOCKS_PER_SEC;<br> printf ("cps=%d ", CLOCKS_PER_SEC);
<br> printf("wall=%g, cpu=%g, us=%g\n",w,c,d);<br>}<br clear="all"><br>-- <br>Paulo Roma Cavalcanti<br>LCG - UFRJ