Subject: Re: B20.1 clock() function bug?
From: [email-masked] (Brian P Kasper)

1 Feb 1999 14:07:00 -0800
Message-ID: <0240136B5C1E101A*/c=us/admd=0/prmd=aero/o=notes/s=Kasper/g=Brian/i=P/.cygnus.gnu-win32@MHS>
To: [email-masked]

><<   The clock function's era begins (with a value of 0) when the
>   C program starts to execute.>>
>
>I don't think you can count on that.  It should return a value of type
>clock_t, which overflows and starts over periodically.

I don't think the above quote says anything about the return value
overflowing, just that it starts at 0 when the program begins
execution.

This makes sense, as when I checked K&R (as you suggested below,
oops, shoulda done that first off), clock() is defined as

"clock returns the processor time used by the program since the
beginning of execution, or -1 if unavailable.  clock()/CLK_TCK
is a time in seconds."

So, clock() should in fact return a *processor* time, not an
absolute time.  Microsoft may have implemented it differently
(no surprise there).

><<   It returns times measured in 1/CLOCKS_PER_SEC (which
>   equals 1/1000 for Microsoft C).>>
>
>Always use the local CLOCK_T.  Who knows when it might change or when you
>might use a different brand of software.

Yeah, I know -- I am using the #defined value.  The goal here
*is* software portability.  I'm just surprised that I'm getting
different results on the same OS with 2 different compilers.

><< Am I misinterpreting the behavior of clock()?  Does it return
> user time instead of absolute system time? >>
>
>Read your C textbook.  That's what it should do, at least on NT.  On W95, 
this

Did that.  Should have done that earlier.

Thanks for the response.  I'm going to investigate compiler-independent
timing.

-Brian
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".