Bug #16545 [Com]: parse_url is *slow*

From: Date: Wed, 12 Jun 2019 17:29:32 +0000
Subject: Bug #16545 [Com]: parse_url is *slow*
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-221251@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=16545&edit=1

 ID:                 16545
 Comment by:         icarus10149 at gmail dot com
 Reported by:        ssb at fast dot no
 Summary:            parse_url is *slow*
 Status:             Closed
 Type:               Bug
 Package:            Performance problem
 Operating System:   RedHat 7.2
 PHP Version:        4.1.2
 Block user comment: N
 Private report:     N

 New Comment:

The following:
list(,,$url['scheme'],,$url['host'],,$url['port'],$url['path'],,$url['query'])

Should be:
list(,,$url['scheme'],,$url['host'],,$url['port'],,$url['path'],,$url['query'])

Missing the double comma between $url['port'] and $url['path']


Previous Comments:
------------------------------------------------------------------------
[2002-10-06 11:27:59] iliaa@php.net

This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.



------------------------------------------------------------------------
[2002-04-11 05:32:04] ssb at fast dot no

parse_url() is over 30 times slower than a PHP code doing the same thing with preg_match.  Check
this out:

parse_url.php:

<?php

for ($i = 0; $i < 50000; $i++) {
    $fullurl = "http://www.example.com:80/blah/bing?foo=bar&gazonk=true";
    $url = parse_url($fullurl);
}

?>

$ time php parse_url.php 

real	1m41.777s
user	1m35.770s
sys	0m0.200s


preg_match.php:

<?php

for ($i = 0; $i < 50000; $i++) {
    $fullurl = "http://www.example.com:80/blah/bing?foo=bar&gazonk=true";
    preg_match('!^(([^:/?#]+):)?(//([^/:?#]*)(:(\d+))?)?([^?#]*)(\\?([^#]*))?(#(.*))?!',
$fullurl, $matches);
   
list(,,$url['scheme'],,$url['host'],,$url['port'],$url['path'],,$url['query'])
= $matches;
}

?>

$ time php preg_match.php

real	0m2.950s
user	0m2.940s
sys	0m0.000s



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=16545&edit=1


Thread (3 messages)

« previous php.bugs (#221251) next »