Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Mar 2005
    Posts
    59
    Thanks
    1
    Thanked 0 Times in 0 Posts

    PHP HTML Output Processing Time length Not Proporitonal

    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 Code:
    <?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);
    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.

  • #2
    Regular Coder
    Join Date
    Mar 2006
    Posts
    238
    Thanks
    3
    Thanked 37 Times in 37 Posts
    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
    Code:
    php_value memory_limit 128M
    Try 256M too.

    And which is the current memory limit ?
    PHP Code:
    echo ini_get('memory_limit'); 

  • #3
    New Coder
    Join Date
    Mar 2005
    Posts
    59
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •