Connecting Tech Pros Worldwide Forums | Help | Site Map

Having trouble with clock function

Stu
Guest
 
Posts: n/a
#1: Jun 19 '07
Hi guys,

I've been having trouble getting the clock function to work portably,
please could I get some thoughts?

<Possibly OT comments>
It works fine on my laptop (under WinXP) and on my office computer
(under Linux), but I have to write some code for the system simulator
for the Cell BE processor (the thing inside the PS3), which is
apparently a PPC architecture, and I can't get the clock function to
return anything sensible - it returns 0 every time for no apparent
reason.
</Possibly OT comments>

The following is a cut-down version of my code which exhibits the
problem I'm having :) Any thoughts please? As far as I know the clock
function specification says something like "give the best result you
can", but surely "return 0;" wasn't what was in mind...?

#include <iostream>
#include <time.h>

int main()
{
for(;;) // (this is just example code)
{
std::cout << clock() << std::endl;
}

return 0;
}

Cheers,
Stu


Lionel B
Guest
 
Posts: n/a
#2: Jun 19 '07

re: Having trouble with clock function


On Tue, 19 Jun 2007 07:18:27 -0700, Stu wrote:
Quote:
Hi guys,
>
I've been having trouble getting the clock function to work portably,
please could I get some thoughts?
>
<Possibly OT comments>
It works fine on my laptop (under WinXP) and on my office computer
(under Linux), but I have to write some code for the system simulator
for the Cell BE processor (the thing inside the PS3), which is
apparently a PPC architecture, and I can't get the clock function to
return anything sensible - it returns 0 every time for no apparent
reason.
</Possibly OT comments>
>
The following is a cut-down version of my code which exhibits the
problem I'm having :) Any thoughts please? As far as I know the clock
function specification says something like "give the best result you
can", but surely "return 0;" wasn't what was in mind...?
Maybe not... OTOH it doesn't violate the standard. You'd probably be best
off asking on a forum for your platform.

--
Lionel B
Stu
Guest
 
Posts: n/a
#3: Jun 20 '07

re: Having trouble with clock function


On Jun 19, 3:31 pm, Lionel B <m...@privacy.netwrote:
Quote:
On Tue, 19 Jun 2007 07:18:27 -0700, Stu wrote:
Quote:
Hi guys,
>
Quote:
I've been having trouble getting the clock function to work portably,
please could I get some thoughts?
>
Quote:
<Possibly OT comments>
It works fine on my laptop (under WinXP) and on my office computer
(under Linux), but I have to write some code for the system simulator
for the Cell BE processor (the thing inside the PS3), which is
apparently a PPC architecture, and I can't get the clock function to
return anything sensible - it returns 0 every time for no apparent
reason.
</Possibly OT comments>
>
Quote:
The following is a cut-down version of my code which exhibits the
problem I'm having :) Any thoughts please? As far as I know the clock
function specification says something like "give the best result you
can", but surely "return 0;" wasn't what was in mind...?
>
Maybe not... OTOH it doesn't violate the standard. You'd probably be best
off asking on a forum for your platform.
>
--
Lionel B
Ok, thanks, will do.

Cheers,
Stu

Closed Thread


Similar C / C++ bytes