Annoying problem
| From: | J-F Mammet | Date: | Fri, 11 Feb 2000 09:17:37 +0000 |
| Subject: | Annoying problem | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-10091@lists.php.net to get a copy of this message | ||
Hi all.
I'm using the latest CVS version of PHP4 to develop my new site. However I have a big performance problem.
My template system gets all the non parsed templates from the database, parses them and put the result in a string. For testing this string is 63 kbytes big. Until now everything is ok and for a rather complex page it takes .25 seconds to get the final string, which is good.
Now comes the strange part. All I want to do is send the string to the customer browser.
All I do is :
echo $Templates["Contenu_Nom"]["main"];
This simple function takes 3 seconds ! A printf takes about the same time.
If I do :
for ($i=0;$i<strlen($Templates["Contenu_Nom"]["main"]);$i++)
echo $Templates["Contenu_Nom"]["main"][$i];
The page is generated in 1.4 seconds, which I believe is normal since this loop is ugly 8-p
I filed a bug report quite some time ago but I never had this problem with php3 (but it takes quite much more time to parse my templates)
I don't know what I can give you guys for testing, here is a sample script :
<?
function Begin_Chrono()
{
global $Debut_Chrono;
$Debut_Chrono = microtime();
}
function End_Chrono()
{
global $Debut_Chrono;
$Fin = microtime();
$Temp = explode(" ",$Debut_Chrono);
$Secondes_Debut = $Temp[1];
$Milli_Debut = $Temp[0];
$Temp = explode(" ",$Fin);
$Secondes_Fin = $Temp[1];
$Milli_Fin = $Temp[0];
$Secondes = $Secondes_Debut - $Secondes_Fin;
$Milli = $Milli_Debut - $Milli_Fin;
$Temps = abs($Secondes + $Milli);
echo "\n\n<!Elapsed time : $Temps>";
}
Begin_Chrono();
for ($i=0;$i<63000;$i++)
{
$string .= "a";
}
End_Chrono();
Begin_Chrono();
echo $string;
End_Chrono();
?>
the result is :
<!Elapsed time : 0.322759>
lots of a
<!Elapsed time : 3.104748>
Yes my time functions are ugly 8)
my configure line is :
./configure --disable-debug --with-apache=/home/blah/apache_1.3.9 --with-gd --with-mysql --enable-inline-optimization --disable-trans-sid
Thanks for your help, this problem is here since beta1 !
Best Regards.
J-F Mammet
webmaster@softgallery.fr