Re: building something with nanotime

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jim Stapleton wrote:

> although not likely, the code may cross a day threshold, and
> gettimeofday could be problematic. What is the simplest way to get a
> time interval on something that may cross a day threshold (in ms or
> preferrably ns?). I know clock() can get me ticks, but it'll take work
> to conver that to second (any simple way to do that)? I understand
> clock is for the given thread, and not absolute time, but both may be
> relevant at some point.

Despite 'day' in its name, gettimeofday() has nothing to do with days. 
Its return value is seconds since the epoch.

http://www.opengroup.org/onlinepubs/009695399/functions/gettimeofday.html
http://www.gnu.org/software/libc/manual/html_node/High_002dResolution-Calendar.html

However if you are trying to measure performance of an operation you
shouldn't use calendar time, you should use processor time.  Converting
to seconds is done by simply dividing by CLOCKS_PER_SEC, nominally one
million.

http://www.opengroup.org/onlinepubs/009695399/functions/times.html
http://www.gnu.org/software/libc/manual/html_node/Processor-Time.html

Brian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux