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 &quot;getus&quot;, which seems to do what I need. Is this the right course?<br><br>Thanks. <br>__________________________________________________________________
<br><br>#include &lt;sys/time.h&gt;<br>#include &lt;time.h&gt;<br>#include &lt;stdio.h&gt;<br><br>#define getus(tv) (tv.tv_sec*CLOCKS_PER_SEC + tv.tv_usec)<br>int main() {<br>&nbsp; clock_t ca,cb;<br>&nbsp; time_t wa,wb;<br>&nbsp; struct timeval tva, tvb;
<br>&nbsp; double c,w;<br>&nbsp; double d;<br>&nbsp; char s[10];<br>&nbsp; ca = clock();<br>&nbsp; wa = time(0);<br>&nbsp; gettimeofday(&amp;tva, NULL);<br>&nbsp; printf(&quot;hit enter when ready &quot;);<br>&nbsp; fflush (stdout);<br>&nbsp; gets(s);<br>&nbsp; cb = clock();
<br>&nbsp; wb = time(0);<br>&nbsp; gettimeofday(&amp;tvb, NULL);<br>&nbsp; c = (double) (cb-ca);<br>&nbsp; w = (double) difftime(wb,wa);<br>&nbsp; c /= (double) CLOCKS_PER_SEC;<br>&nbsp; d = (getus(tvb) - getus(tva))/(double) CLOCKS_PER_SEC;<br>&nbsp; printf (&quot;cps=%d &quot;, CLOCKS_PER_SEC);
<br>&nbsp; printf(&quot;wall=%g, cpu=%g, us=%g\n&quot;,w,c,d);<br>}<br clear="all"><br>-- <br>Paulo Roma Cavalcanti<br>LCG - UFRJ