[wp-trac] [WordPress Trac] #23132: wp_timezone_override_offset() has notiecable performance hit

WordPress Trac noreply at wordpress.org
Sun Jan 6 22:05:19 UTC 2013


#23132: wp_timezone_override_offset() has notiecable performance hit
-----------------------------+-------------------------
 Reporter:  Rarst            |       Type:  enhancement
   Status:  new              |   Priority:  normal
Milestone:  Awaiting Review  |  Component:  Date/Time
  Version:  3.5              |   Severity:  minor
 Keywords:                   |
-----------------------------+-------------------------
 While wandering through XHProf generated callgraph of my test stack I came
 upon `wp_timezone_override_offset()` eating 3.4% of runtime (73 calls). I
 do not expect noticeable resource consumption from such minor
 configuration-related function.

 The obvious performance aspect is that it creates and discards two objects
 (`DateTime` and `DateTimeZone` - latter seemingly more heavy) per each
 call, while calculating same result each run.

 The less obvious aspect is that the only use of this function is to pre-
 filter `gmt_offset` option, and it essentially hijacks option cache for
 it.

 Possible solutions:

  - calculate result once per run and cache in static variable inside
 function (straightforward, but retains multiple function call)
  - filter `gmt_offset` on set rather than get (more involved)
  - scrap the extra function and/or option altogether? is there still
 practical need for having two options for timezone information?

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/23132>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list