Subject: [Boost-bugs] [Boost C++ Libraries] #11806: microsec_clock::universal_time() is needlessly slow
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-11-19 15:58:36
#11806: microsec_clock::universal_time() is needlessly slow
------------------------------+--------------------------
Reporter: jzwinck@⦠| Owner: az_sw_dude
Type: Bugs | Status: new
Milestone: To Be Determined | Component: date_time
Version: Boost 1.55.0 | Severity: Optimization
Keywords: |
------------------------------+--------------------------
The
[http://www.boost.org/doc/libs/1_55_0/doc/html/date_time/posix_time.html
documentation] for `microsec_clock::universal_time()` says:
> Get the UTC time using a sub second resolution clock. On Unix systems
this is implemented using !GetTimeOfDay.
In fact it is implemented partly using `gettimeofday()` but also
`gmtime_r()`. Once you unwrap all the layers, the flow is something like
this:
sec,nsec = gettimeofday()
date,time = gmtime(sec)
sec,nsec = ptime(date,time)
return sec+nsec/1000
The problem is that `gmtime_r()` is very slow, relative to the other
operations involved here, and it is completely unnecessary. A call to
`gettimeofday()` on Unix is all you need to implement `universal_time()`.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/11806> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:19 UTC