clock() seems not work !
Quoted 6 lines · Yang
i am writting applications based ppc+MVL3.0, which i want to get CPU
time,butclock()seems not work for me, for this i did a simple test,as follows:
/*----------------*/
while(1)
Quoted 7 lines
{ 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/