...

View Full Version : PHP HTML Output Processing Time length Not Proporitonal



ideffect
02-10-2010, 09:57 AM
Hey everyone,

I'm working on completing a large website and I am monitoring the processing time for them since there is a lot going on. The website includes a lot of files and some of the pages generate a lot of HTML.

There was one page that has 600 lines of code and the processing time was much higher than any other page (.5+ seconds vs .007ish). I figured there was a problem with one of the many loops or something going on. On further examination, I noticed that as long as I did not include one random file that outputs HTML, the load time goes to normal. Looking at it even further, I was able to randomly remove about 15 lines of HTML and suddenly the load time drops.

So it seems like I hit some invisible wall that does not alter or stops processing the page BUT it takes a disproportional amount of time to process. I did a character count to see how many characters it takes and the magic number is 40182.

I updated my version of PHP to 5.3.1 (from 5.2.11). I am wondering if someone knows anything about this and if there is a simple option that needs to be changes(doubt it) and if anyone can test it. I made a simple script to cause the problem. If you copy and paste it, it should work.


<?php
$time_start = microtime ( true );
$i = 1;
while ( $i < 486 ) {
$i ++;
$q = "<p>This is line number $i. Lets see how many to make this script run slow...</p>
";
echo "$q";
}
echo "This is line is filler to see wha";
//This makes 40182 characters
$time_end = microtime ( true );
$time = round ( $time_end - $time_start, 3 );
echo "<p>Process Time: $time seconds</p>";
?>

When I run the above, it takes about .5 seconds. If I change the while statement to 485, the problem goes away or even remove the "a" at the end of the line that reads echo "This is line is filler to see wha"; and the process time is .0001.

Let me know what you think and if it happens to you.

SKDevelopment
02-10-2010, 01:04 PM
Interesting. I have got 0.001 seconds both at 485 and 486 at several tests. Once I got 0.002 seconds for 486 though ...

Maybe it would not help really much , but still ... Do not have output buffering turned on at your server ? Please notice that it could be turned on not only righ tin the script, but in php.ini. This is why I have asked ...

Also could you try to increase the PHP memory limit and test again ? Try to add to .htaccess the line


php_value memory_limit 128M

Try 256M too.

And which is the current memory limit ?


echo ini_get('memory_limit');

ideffect
02-10-2010, 07:40 PM
Thanks for the suggestion.

I upped the memory in my php.ini file to 256(and verified it) with no change. Mabyee try 487 or 500 in the while loop.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum