Skip to contentSkip to conversation

clock() seems not work !

DISCUSSION Eugene Surovegin 1 participant 1 message Feb 16, 2004 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 6 lines · Yang

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)

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/