TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: GEORGE WHITE
from: Jasen Betts
date: 1998-06-22 16:21:00
subject: CLOCK()ING IN MY SLEEP()

GW> Bit odd really, as the two compilers I've looked at so far say clock()
GW> measures time from program start.

It doesn't even do that. help-pc says it measures elapsed processor-time
for the process, so under an multitasking O/S it could well return a lower
value... (my turbo-c manual agrees) but clock under turbo-c 2.0 isn't
multitasker aware.

After some experimentation under linux, it appears that a clock counts only
the time that the process is actually executing, in a program that does a
sleep(10) (10 seconds) clock returns 0 (no time elapsed)

Two processes executing concurrently would share the "clocks" and
would each
only see half the elapsed time.

This suggests that the (portable) sleep in snippets is broken in that it
doesn't stop clock(). And that uclock is broken in that it doesn't measure
cpu-time.

I have no idea of what would happen under windows or OS/2 or on an Amiga or a
Mac.

                        

--- EzyQwk V1.20 01fa018d
* Origin: CSS Brisbane, Qld, Australia. [61-7-3367-3890] (3:640/350)
SEEN-BY: 396/1 622/419 632/371 633/260 267 270 371 634/397 635/506 728
SEEN-BY: 670/213 218
@PATH: 640/350 201 270/101 396/1 633/260 635/506 728 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.