Subject: [Boost-bugs] [Boost C++ Libraries] #2718: local_date_time noticeably faster than ptime
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-02-03 09:14:19
#2718: local_date_time noticeably faster than ptime
------------------------------+---------------------------------------------
Reporter: oneill1979 | Owner: az_sw_dude
Type: Bugs | Status: new
Milestone: To Be Determined | Component: date_time
Version: Boost 1.37.0 | Severity: Optimization
Keywords: |
------------------------------+---------------------------------------------
We noticed recently that using a local_date_time in tight loops was
several times faster than using a ptime object. As these are both based
largerly on the same template code this was a surprise. It appears this is
caused by the implementation of the operater+=/-= and was wondering if
there was any justification for the difference or if this was just an
oversight.
{{{
#!cpp
//.\boost\date_time\local_time\local_date_time.hpp
local_date_time_base operator+=(const time_duration_type& td)
{
this->time_ = time_system_type::add_time_duration(this->time_,td);
return *this;
}
}}}
{{{
#!cpp
//.\boost\date_time\time.hpp
time_type operator+=(const time_duration_type& td)
{
time_ = (time_system::get_time_rep(date(), time_of_day() + td));
return time_type(time_);
}
}}}
It looks like the ptime implementation is doing extra work to split the
ptime into date and time_duration components and if it is changed to
follow a similar pattern to that used in the local time the performance is
then indistinguishable.
{{{
#!cpp
//.\boost\date_time\time.hpp
time_type operator+=(const time_duration_type& td)
{
this->time_ = time_system::add_time_duration(this->time_, td);
return time_type(time_);
}
}}}
I can only think that maybe this was done to work around an issue and in
which case should the same then be applied to the local time
implementation?
[http://www.nabble.com/user/SendEmail.jtp?type=user&user=627065 email via
nabble]
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/2718> 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:49:59 UTC