[Cialug] Seconds only timestamp

Zachary Kotlarek zach at kotlarek.com
Tue Jun 17 23:45:02 CDT 2014


On Jun 15, 2014, at 4:52 PM, Brian Wood <woodbrian77 at gmail.com> wrote:

> Is there an api that returns just the number of seconds?  Currently
> I'm using clock_gettime and  CLOCK_REALTIME_COARSE.  The
> docs say that CLOCK_REALTIME_COARSE is;
> 
> "A faster but less precise version of CLOCK_REALTIME."
> 
> I don't know how coarse it is, but I only care about the seconds.


CLOCK_*_COARSE returns the time as it was at the last tick — so typically something around 1ms accuracy depending on your tick configuration.

Depending on where you’re running (new-ish libc, hardware with synced TSC) gettimeofday() might already be using a userspace time source, but you can select for yourself using CLOCK_*_COARSE.

	Zach

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2749 bytes
Desc: not available
URL: <http://cialug.org/pipermail/cialug/attachments/20140617/e71d6e7f/attachment.bin>


More information about the Cialug mailing list