#16545 [Opn->Csd]: parse_url is *slow*
| From: | iliaa@php.net | Date: | Sun, 06 Oct 2002 16:27:59 +0000 |
| Subject: | #16545 [Opn->Csd]: parse_url is *slow* | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-21644@lists.php.net to get a copy of this message | ||
ID: 16545
Updated by: iliaa@php.net
Reported By: ssb@fast.no
-Status: Open
+Status: Closed
Bug Type: Performance problem
Operating System: RedHat 7.2
PHP Version: 4.1.2
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2002-04-11 05:32:04] ssb@fast.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 http://bugs.php.net/?id=16545&edit=1