[wp-trac] Re: [WordPress Trac] #8620: Fatal error with HTTP class

WordPress Trac wp-trac at lists.automattic.com
Wed May 27 23:06:21 GMT 2009


#8620: Fatal error with HTTP class
------------------------------------------+---------------------------------
 Reporter:  momo360modena                 |        Owner:  westi 
     Type:  defect (bug)                  |       Status:  closed
 Priority:  normal                        |    Milestone:  2.8   
Component:  HTTP                          |      Version:  2.7   
 Severity:  major                         |   Resolution:  fixed 
 Keywords:  has-patch developer-feedback  |  
------------------------------------------+---------------------------------

Comment(by dd32):

 You seem to be right about the cast vs is_array in PHP5, That wasnt the
 case under PHP4 though.

 3 test cases, run 10,000 each over 2 valid, and 2 invalid cases.

 Function1, as it currently is in core, 0.000035s /run[[BR]]
 Function2, As you promosed it, 0.000014s/run[[BR]]
 Function3, As below, 0.000009s/run[[BR]]
 {{{
 function wp_remote_retrieve_headers2(&$response) {
  if ( is_object($response) || empty($response['headers']) )
   return array();
  return $response['headers'];
 }
 }}}

 is_wp_error() is the expensive part, it accounted for about 0.00002s of
 the total function time, which is about at a rough guess, is about 60% of
 the total function time. It doesnt matter what kind of input was given,
 checking if its an object, and then if the array indicy is empty, is the
 fastest method.

 ..But i'm still -1 to changing the damn thing to something more unreadable
 to pull out an extra 0.0002ms speed increase for a function which is
 rarely used, and even rarer used in a loop. Heck, The HTTP request parsing
 alone uses more than 10,000x the time i bet.. actually, its closer to
 100,000x - 2seconds for the request itself to take place.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/8620#comment:37>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list