unsigned absolute_wallclock(void);
Clock clock_init(char *str);This routine initializes a clock. You give it a string (which is not copied), representing the name of the new clock, and it returns a Clock to be used for all operations on the clock.
The clock operations are clock_start(), clock_stop(), clock_seconds(), clock_milliseconds(), and clock_reset().
unsigned clock_milliseconds(Clock p);This routine returns the current value of a clock, in milliseconds. The value is in milliseconds.
void clock_reset(Clock p);This routine resets a clock, as if it had just been initialized. (You should not need this routine under normal circumstances.)
BOOL clock_running(Clock p);This routine tells you whether or not a clock is running.
double clock_seconds(Clock p);This routine returns the current value of a clock, in seconds. The clock need not be stopped.
void clock_start(Clock p);This routine starts clock n. It is okay if the clock is already going.
void clock_stop(Clock p);This routine stops clock n and adds the time to the accumulated total, unless there have been too many starts and not enough stops. See the introduction.
BOOL clocks_enabled(void);
void disable_clocks(void);
void enable_clocks(void);
void fprint_clock(FILE *fp, Clock p);This routine
void free_clock(Clock p);
char * get_date(void);This routine returns a string representation of the current date and time.
void init_wallclock();This routine initializes the wall-clock timer.
double system_seconds();This routine returns the system CPU time, in seconds, that has been spent on the current process. (System time measures low-level operations such as system calls, paging, and I/O that the operating systems does on behalf of the process.)
unsigned system_time();This routine returns the system CPU time, in milliseconds, that has been spent on the current process. (System time measures low-level operations such as system calls, paging, and I/O that the operating systems does on behalf of the process.)
double user_seconds();This routine returns the user CPU time, in seconds, that the current process has used so far.
unsigned user_time();This routine returns the user CPU time, in milliseconds, that the current process has used so far.
unsigned wallclock();This routine returns the number of wall-clock seconds since init_wallclock() was called. The result is unsigned.
typedef struct clock * Clock;
An unusual feature of these clocks is that they can be used inside of recursive routines. For example, you can start the clock at the beginning of a recursive routine and stop it at the end. If you start it 3 times then stop it three times, it will really stop only on the third call. This works by a counter of the number of extra times the clock has been started, and clock_stop() will stop the clock only when the count is 0. (This feature probably isn't very useful, and most people can ignore it.)
Also here are some routines for getting process system/user CPU time, elapsed wall-clock time, and the time/date.