|
Boost Users : |
Subject: Re: [Boost-users] [date-time] Getting time from midnight in nanoseconds
From: Marsh Ray (marsh_at_[hidden])
Date: 2010-10-22 15:02:04
On 10/22/2010 10:25 AM, ppatel_at_[hidden] wrote:
> Thanks for the reply. I am running on "linux/Ubuntu (Lucid)" version.
> Not sure if there is any API in boost like "clock_gettime()" that
> will return number of nanoseconds monotonically starting at
> unspecified point/midnight (either way).
Why not use clock_gettime(CLOCK_THREAD_CPUTIME_ID, ...) then?
Last I checked, Boost didn't supply a high-res stopwatch. There was one
in the Intel threading library, but it was using CLOCK_REALTIME on Linux
which was not monotonic! You might also look at rdtsc if it's on your
processor.
> My goal is to measure how
> much time a particular API calls takes to run by getting end and
> start time in nanoseconds.
You need a start "timestamp", an end "timestamp", and a way to find the
difference in nanoseconds.
So why bring midnight into it? That introduces all the complexity of
time zones, clock synchronization, daylight saving time, leap seconds, etc.
- Marsh
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