Boost logo

Boost Users :

Subject: Re: [Boost-users] [date-time] Getting time from midnight in nanoseconds
From: Norbert Wenzel (norbert.wenzel.lists_at_[hidden])
Date: 2010-10-22 11:05:11


On 22.10.2010 15:48, ppatel_at_[hidden] wrote:
> Can you please tell me if there is a way to get current time in
> nanoseconds using boost date_time library?
>
> I have tried following but it doesn’t seems to be returning values in
> nanoseconds. I know I have used microsec_clock and that might be the
> problem but not sure what alternate to use.
> [...]
> return duration.total_nanoseconds(); // This call returns values in
> microseconds (last three digits are always zero in returned value)

Hi,

as far as I remember microsecond_clock uses the highest resolution clock
available on your system. On Windows this is a clock with microsecond
resolution (in fact it seems to be even more than one microsecond).

If you are requesting nanoseconds and nanoseconds are not supported by
your system clock all unknowns will be filled with 0.

I do not know of any other solution than yours, so I'm afraid you'll
have to stick to your current resolution.

hth,
Norbert


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net