From: [EMAIL PROTECTED]
Operating system: RedHat 7.2
PHP version: 4.1.2
PHP Bug Type: Performance problem
Bug description: parse_url is *slow*
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 bug report at http://bugs.php.net/?id=16545&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=16545&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=16545&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=16545&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=16545&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=16545&r=support
Expected behavior: http://bugs.php.net/fix.php?id=16545&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=16545&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=16545&r=submittedtwice