mlimber said:
IIRC, it's not defined by the C or C++ standards. Neither language has
the inherent concept of real time vs. process time, so implementations
will vary from platform to platform.
From the C99 draft standard:
7.23.2.1 The clock function
Synopsis
[#1]
#include <time.h>
clock_t clock(void);
Description
[#2] The clock function determines the processor time used.
Returns
[#3] 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.252)
252In 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.
Depends on what you mean by "well-implemented." The function is
required by the standard, yes, but does it function the same
everywhere? No.
No, but it should be reasonably close. Unlike tine(), the semantics for
clock() are fairly well defined. It does waffle a bit, with "best
approximation", but it's not unspecified like time() and time_t.
Brian