Re: Another Tricky Problem I am Messing With (Not Homework)



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
.



Relevant Pages

  • Re: Another Tricky Problem I am Messing With (Not Homework)
    ... This loop probably consumes 100% CPU time while it is doing nothing. ... If the processor time used is not available or its ...
    (comp.lang.c)
  • RE: its going to blow!
    ... The macro itself would not be using processor time (except for a tiny bit of ... overhead) so it must be the spell check itself that is processing so much. ... > This allows staff to spellcheck on our protected documents after completing ... The problem is that when activated, the macro calls ...
    (microsoft.public.excel.programming)
  • Re: Sodding SP2!
    ... soaking up all the CPU time? ... Explorer and svchost, whatever that is. ... What percentage of processor time is each taking? ... When idle "System idle ...
    (uk.rec.sheds)
  • How to get CPU Time of a process programmatically ?
    ... I am trying to obtain the CPU Time like that shown by Task Manager programmatically. ... The only related counter I found was the "%Processor Time" under the Process object. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Macros before begin{document} and checking not to reread files
    ... > 1) I am reorganizing my many, old, sytle, macro, etc. files. ... > macro so I just put file names or subsub directories/file names to ... > 2) some times I want to load files which load subfiles which have ... > already been loaded which results in waste of processor time and errors ...
    (comp.text.tex)