Re: Another Tricky Problem I am Messing With (Not Homework)
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Wed, 19 Sep 2007 00:09:52 -0700
"Bill Reid" <hormelfree@xxxxxxxxxxxxxxxx> writes:
[...]
Ah yes, the non-sequitur vulgar life strategy tactic. I NEVER[...]
asked for any help here, just pointed out your and Keith Thompson's
errors of understanding the "C" standard and computer science
after the 1970s...
I don't believe I've misunderstood the C standard, but I never quite
understood what the program you posted is doing, partly because it
used some non-standard function called "_sleep".
Here's what the standard says about the clock() function
(C99 7.23.2.1):
Synopsis
#include <time.h>
clock_t clock(void);
Description
The clock function determines the processor time used.
Returns
The clock function returns the implementation?s best approximation
to the processor time used by the program since the beginning of
an implementation-defined era related only to the program
invocation. To determine the time in seconds, the value returned
by the clock function should be divided by the value of the macro
CLOCKS_PER_SEC. If the processor time used is not available or its
value cannot be represented, the function returns the value
(clock_t)(-1).
with a footnote:
In order to measure the time spent in a program, the clock
function should be called at the start of the program and its
return value subtracted from the value returned by subsequent
calls.
Now the behavior you described for the program you posted *seemed* to
be inconsistent with that. Either something odd is going on on your
system (e.g., your program uses CPU time even during the _sleep()
calls), or your implementation's clock() function isn't working
properly ("properly" meaning consistently with the standard's
requirements), or something else is going on.
Perhaps you can shed some light on this.
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.
- 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
- Re: Another Tricky Problem I am Messing With (Not Homework)
- From: Mark McIntyre
- Re: Another Tricky Problem I am Messing With (Not Homework)
- From: Bill Reid
- Re: Another Tricky Problem I am Messing With (Not Homework)
- From: Mark McIntyre
- Re: Another Tricky Problem I am Messing With (Not Homework)
- From: Bill Reid
- Another Tricky Problem I am Messing With (Not Homework)
- Prev by Date: Re: Qry : Behaviour of fgets -- ?
- Next by Date: Re: c,c++
- 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
|