On Fri, 30 Aug 2002, Mike Bresnahan wrote:

> Is there a high resolution timer C API on Linux?  If so, what is it's name?
> I need a timer that will give me time with a precision better than seconds,
> e.g. milliseconds.  I'm looking for a C function equivalent to the Java
> function System.currentTimeMillis() and the Win32 functions
> QueryPerformanceCounter() and QueryPerformanceFrequency.

gettimeofday(2)

gettimeof day gets the time into a struct timeval, which is defined as:

struct timeval {
        long tv_sec;        /* seconds */
        long tv_usec;  /* microseconds */
};

and gives the number of seconds and usec since the epoch.

-Chris McKinley