By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,775 Members | 1,399 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,775 IT Pros & Developers. It's quick & easy.

Having trouble with clock function

P: n/a
Stu
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

Jun 19 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Tue, 19 Jun 2007 07:18:27 -0700, Stu wrote:
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
Jun 19 '07 #2

P: n/a
Stu
On Jun 19, 3:31 pm, Lionel B <m...@privacy.netwrote:
On Tue, 19 Jun 2007 07:18:27 -0700, Stu wrote:
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
Ok, thanks, will do.

Cheers,
Stu

Jun 20 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.