Modify

Opened 9 years ago

#2718 new Bugs

local_date_time noticeably faster than ptime

Reported by: oneill1979 Owned by: az_sw_dude
Milestone: To Be Determined Component: date_time
Version: Boost 1.37.0 Severity: Optimization
Keywords: Cc:

Description

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.

    //.\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;
    }
    //.\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.

    //.\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?

email via nabble

Attachments (0)

Change History (0)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain az_sw_dude.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.