Mail Archives: cygwin/1999/02/02/03:04:46
><< 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
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".
- Raw text -