SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist ucahg's Avatar
    Join Date
    Apr 2001
    Location
    Sarnia, Ontario, Canada
    Posts
    434
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Performance Issues - Output Buffer

    Hi, if I wanted to be able to declare headers at any point in a php file, I could put ob_start() at the front and ob_end_flush() at the end of the file, (or in the prepend and append files). Anyway, I was wondering if this would make a big difference in performance and speed. Does anybody know if using the output buffer puts a strain on the page making it take significantly longer to load? Thanks.

  2. #2
    SitePoint Evangelist ucahg's Avatar
    Join Date
    Apr 2001
    Location
    Sarnia, Ontario, Canada
    Posts
    434
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anybody?

    Should I set up a timing function to figure it out instead, and if so how would I do so, since the page would be created in different times? I'd need a "This page has been created in x number of seconds" or something like that on the page to compare. Any help is appreciated.

  3. #3
    SitePoint Wizard
    Join Date
    Jul 1999
    Location
    Chicago
    Posts
    2,629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can't help you with the first part, but to time code down to the millisecond, do this:

    at the beginning:
    PHP Code:
    list($bmic,$bsec) = split(" "microtime());
    $begtime $bmic $bsec
    at the end:
    PHP Code:
    list($emic$esec) = split(" ",microtime());
    $endtime $emic $esec;
    $runtime sprintf("%01.1f", (($endtime $begtime) * 1000)); 
    $runtime will be something like "23.5" and it is the number of milliseconds the code execution took.

  4. #4
    SitePoint Evangelist ucahg's Avatar
    Join Date
    Apr 2001
    Location
    Sarnia, Ontario, Canada
    Posts
    434
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Every time I reloaded it changed the time. Sometimes it took 90, sometimes 70.

    The first time the page loaded without the output buffer, the page took 74, and the first time with the output buffer, 149. But then if I tried again, without the OB, 90, and with the OB, 74.

    So I'm not really sure.


Bookmarks

Posting Permissions

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