On Mon, Feb 16, 2004 at 11:58:07AM +0800, Yang wrote:
>
>  i am writting applications based ppc+MVL3.0, which i want to get CPU
> time,but clock() seems not work for me, for this i did a simple test,as
> follows:
> /*----------------*/
>   while(1)
>       {
>       printf("current time is %ld \n",clock());
>         sleep(1);
>       }
> /*----------------*/
>      But it printed the same value all the while. How is it?
>

What do you expect from this function?

Did you read manual entry for clock()?

On POSIX systems clock() returns (number of seconds * CLOCKS_PER_SEC)
spent by the process, not a system time/tick count...

Your program is doing _nothing_, so it's normal that clock() returns
the same number. Change sleep(1) to some busy loop and you'll see the
difference.

Eugene.

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/



Reply via email to