473,406 Members | 2,954 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Having trouble with clock function

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
2 1992
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Agency | last post by:
I'm still working on the bpm counter. I need to have at least 2 displays that are not static. One would be a clock/running time and the other would should the current beat count. How would I...
9
by: Gino Elloso - Philippines | last post by:
Hello, I made a webpage ( @ Geocities Free Webpages ) that contains a mousetrail clock script. I simply copied the script ( including all html tags ) exactly as it was from a source webpage (...
1
by: Weston C | last post by:
In the course of trying to build a simple clock, I've run into a problem using the setInterval (and setTimeout) function. http://weston.canncentral.org/misc/tkeep/tkeep.html...
33
by: Pushkar Pradhan | last post by:
I'm using clock() to time parts of my code e.g. clk1 = clock(); /* code */ clk2 = clock(); /* calculate time in secs */ ...... clk1 = clock(); /* code */ clk2 = clock();
18
by: roberts.noah | last post by:
Ok, so I am trying to establish how boost.timer works and I try a few things and afaict it doesn't. So I open the header to see why and run some tests to establish what is going on and it all...
30
by: Matt | last post by:
Does clock_t clock() measure real time or process time? Unless I have missed something, Stroustrup's treatment in TC++PL (section D.4.4.1) is none too clear on that question. Is clock()...
2
by: cpptutor2000 | last post by:
Could some C guru suggest some possible solution to my problem? I am trying to simulate a clock and I have tried using 'gettimeofday' and some related C library functions, but I am not getting what...
12
by: cenktarhancenk | last post by:
is there a way to display a ticking clock in a web page using javascript? but not in a textbox, rather as text that i can change the style, font etc. cenk tarhan
1
by: ANB8503 | last post by:
Hello, I have created the below script; however, it's not showing in the box like it should... Help please!! I am running out of time to submit this assignment! Thanks in advance!! ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.