boost::posix_time::ptime - performance
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? -- ------------------------------------------------------------------- Ph : (732) 647 5679 Email: khandelwal.amit@gmail.com Web: http://khandelwal.amit.googlepages.com/home -------------------------------------------------------------------
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
participants (2)
-
amit khandelwal
-
Václav Haisman