Jump to content

Recommended Posts

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.