Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::posix_time::ptime - performance
From: Václav Haisman (v.haisman_at_[hidden])
Date: 2008-09-09 16:11:58


amit khandelwal wrote, On 9.9.2008 19:33:
> For 1 million invocations of boost::posix_time::ptime ptm
> (boost::posix_time::microsec_clock::local_time() ); // Get current
> time
> It takes about 1 sec.
>
> However, gettimeofday takes about 300 ms.
>
> gettimeofday takes about 300 ms.
> // struct timeval tv;
> // gettimeofday(&tv, NULL);
>
> Any pointers on why it takes so long? I want to ensure that timestamp call
> are not expensive. Any suggestion/recommendation?
That depends on OS a lot. Linux' getttimeofday() is not that accurate but the
call should be realtively cheap. On the other hand, FreeBSD's gettimeofday()
is more accurate but the call is a lot more expensive, because of
kernel/userland context switch.

--
VH

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