Homec4science

Improve time localization code

Authored by epriestley <git@epriestley.com> on Sep 27 2011, 18:03.

Description

Improve time localization code

Summary:

  • We throw on a missing date right now, in the DateTime constructor. This can

happen in reasonable cases and this is display code, so handle it more
gracefully (see T520).

  • This stuff is a little slow and we sometimes render many hundreds of dates

per page. I've been seeing it in profiles on and off. Memoize timezones to
improve performance.

  • Some minor code duplication that would have become less-minor with the

constructor change, consolidate the logic.

  • Add some unit tests and a little documentation.

Test Plan:

  • Ran unit tests.
  • Profiled 1,000 calls to phabricator_datetime(), cost dropped from ~49ms to

~19ms with addition of memoization. This is still slower than I'd like but I
don't think there's an easy way to squeeze it down further.

Reviewers: ajtrichards, jungejason, nh, tuomaspelkonen, aran

Reviewed By: ajtrichards

CC: aran, ajtrichards, epriestley

Differential Revision: 966

Details

Committed
epriestley <git@epriestley.com>Sep 27 2011, 18:25
Pushed
aubortJan 31 2017, 17:16
Parents
rPH016b060aeafd: Add a relation table for Revisions to local commit hashes
Branches
Unknown
Tags
Unknown

Event Timeline

epriestley <git@epriestley.com> committed rPH2fc3acc9699f: Improve time localization code (authored by epriestley <git@epriestley.com>).Sep 27 2011, 18:25