Bug #11018 Updated: ereg_replace takes a preposterous amount of time w.r.t. PHP3
| From: | vigna at dsi dot unimi dot it | Date: | Tue, 22 May 2001 08:12:52 +0000 |
| Subject: | Bug #11018 Updated: ereg_replace takes a preposterous amount of time w.r.t. PHP3 | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-56202@lists.php.net to get a copy of this message | ||
ID: 11018
User Update by: vigna@dsi.unimi.it
Status: Open
Bug Type: Performance problem
Operating system: Linux
PHP Version: 4.0.4pl1
Description: ereg_replace takes a preposterous amount of time w.r.t. PHP3
> What is that second regex doing? It looks like there is
missing \\ in there.
There are backslashes missing everywhere, apparently eaten
by the submission form.
I tried with preg_replace() and everything works fine now.
However I would like to hear an official comment about
this: if this is a "normal" status for the ereg_* family,
I'll stop using it. Performance is simply unacceptable.
I am a bit uncomfortable about using Perl stuff. POSIX is a
standard, Perl is not. But if the word is "drop ereg", it's
OK anyway.
Previous Comments:
---------------------------------------------------------------------------
[2001-05-22 10:02:25] brianlmoon@php.net
What is that second regex doing? It looks like there is a missing in there.
Just for testing, have you tried using preg_replace instead of ereg. The preg functions are faster
and more reliable.
---------------------------------------------------------------------------
[2001-05-22 09:50:52] derick@php.net
I suggest using preg_replace and try to splitup the $bib variabele into smaller parts (i.e. per
line).
Can you see if this works better for you?
Derick
---------------------------------------------------------------------------
[2001-05-22 09:45:22] vigna@dsi.unimi.it
My publication page
(http://gongolo.usr.dsi.unimi.it/~vigna/papers) is generated
with PHP. Part of the generation process includes the
following regular expression substitutions:
$bib = ereg_replace("([0-9]+)--([0-9]+)", "\1-\2",$bib);
$bib = ereg_replace("{((['`]|w)+)}", "\1", $bib);
$bib is a variable containig about 20K of text generated by
a BibTeX style. Everything worked fine with PHP 3, but since
I installed PHP 4, the page is output in >20 seconds.
Indeed, there where other 10 substitutions, and initially
the page wouldn't simply display because of server timeout.
I changed whenever possible ereg_replace to str_replace, but
of course the two substitutions above need regular
expressions. They increase the page serving time of about
15s. Computation time was negligible with PHP 3.
The strange thing is that the page is _serverd_ slowly. One
would expect that there is a long wait, and then the page is
served all at one time. Instead, there is a long wait, and
then the page is served slowly. Eliminating the two regular
expressions above solves the problem (but serves the wrong
page 8^).
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=11018