Re: Another Tricky Problem I am Messing With (Not Homework)
- From: Mark McIntyre <markmcintyre@xxxxxxxxxxx>
- Date: Wed, 12 Sep 2007 23:14:28 +0100
On Wed, 12 Sep 2007 04:58:42 GMT, in comp.lang.c , "Bill Reid"
<hormelfree@xxxxxxxxxxxxxxxx> wrote:
The clock function returns the implementation's best approximation
to the processor time used by the program
Well, yeah, it's supposed to tell you how long the program has
been running.
No, its supposed to tell you the processor time used. Which is
entirely different to wallclock time.
I assume you're not used to multitasking operating systems.
On my system the program running time is counted
in milliseconds starting from zero as soon as the program starts.
However this isn't what clock() measures.
I have no idea how your '_sleep' function works. I suspect that
either '_sleep' delays for a specified interval of CPU time,
No possibility it just delays execution of the program for a
specified amount of time regardless of the "CPU time"?
Its possible, but since its a nonstandard function, we can't say.
Since it is nominally a "multi-tasking" single-processor system it
must be sharing that CPU time with all the other programs I'm running,
but that doesn't seem to affect the perceived time as the program
runs or timings returned by clock() much.
My guess: when you're running this process, it takes 100% of hte CPU
available for the duration of hte "busy wait" loop. Try running a huge
numerical simulation at the same time, say BOINC or converting a nice
big AVI into MPG. Either you will see a difference, or your
background jobs will all freeze, or your clock() is nonstandard and
you need a new compiler.
Note that clock_t could be signed, unsigned, or floating-point, and
CLK_TCK isn't defined in standard C; the correct macro is
CLOCKS_PER_SEC.
Yeah, I noticed that, but for this development package, they
use a different name for the same macro,
It can't be the same macro if it has a different name....
--
Mark McIntyre
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
.
- Follow-Ups:
- Re: Another Tricky Problem I am Messing With (Not Homework)
- From: Bill Reid
- Re: Another Tricky Problem I am Messing With (Not Homework)
- References:
- Another Tricky Problem I am Messing With (Not Homework)
- From: joebenjamin
- Re: Another Tricky Problem I am Messing With (Not Homework)
- From: Miguel Guedes
- Re: Another Tricky Problem I am Messing With (Not Homework)
- From: Bart van Ingen Schenau
- Another Tricky Problem I am Messing With (Not Homework)
- Prev by Date: Re: Sizes of Integer Types
- Next by Date: Re: Anyone have any ideas on this one..... (OT)
- Previous by thread: Re: Another Tricky Problem I am Messing With (Not Homework)
- Next by thread: Re: Another Tricky Problem I am Messing With (Not Homework)
- Index(es):
Relevant Pages
|