Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9179989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:56:16+00:00 2026-06-17T17:56:16+00:00

I am writing an application in PHP, and I decided to do some testing

  • 0

I am writing an application in PHP, and I decided to do some testing on my own to determine how well PHP handles buffers and buffering. Specifically, I wanted to see if manually calling ob_start() and ob_flush() would have a huge effect on my program.

I conjured up 10KB of lorem ipsum and went to work. I put a timer in PHP at the start and end of a for loop that writes the 10KB of lipsum (in display:none div blocks) 100 times, for a total of 1MB of data, which I figured would be enough work that random CPU load wouldn’t throw off my data too much.

Besides the PHP timer, I popped open Chrome’s developer tools (F12) and recorded the “time” and “latency” field. If I have my terminology correct, the “time” is the total amount of time the page took to respond, and render, and “latency” is just the time until the page first received data from the server.

So here’s the mystery: When I do nothing but write the 10KB of lipsum 100x, my averages are:

PHP Time: 0.00630ms
Chrome Time: 565.6ms
Chrome Latency: 28.3ms

When I call ob_start() at the very beginning, and ob_flush() at the very end:

PHP Time: 0.00792ms
Chrome Time: 540ms
Chrome Latency: 33ms

HOWEVER, and here’s the mystery – when I call ob_start() and ob_flush() at the beginning and end of each 10KB block of text, my Chrome-reported latency spikes by 4x.

PHP Time: 0.005814ms
Chrome Time: 624.7ms
Chrome Latency: 134.9ms ???

As far as I know, the chrome latency should be cut by 100x, since I’m flushing the buffer 1/100 of the way through the PHP output. I know that the ob_start() and ob_flush() operate on a higher buffer, and they actually flush into a lower buffer, I would expect that lower buffer to flush at the same intervals, meaning I would see about the same latency.

My test rig is a very modest Intel ATOM netbook with Nvidia ION graphics, Windows 7 home premium (32-bit) and WAMPserver running Apache 2.2.22 with pretty much default settings. I used Chrome 24.0.1312.52 m. CPU load was moderate but not 100% during the tests, and my ram was nowhere near full.

Test Code:
http://pastebin.com/zf62Y4yz

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T17:56:17+00:00Added an answer on June 17, 2026 at 5:56 pm

    ob_flush sends the content out to the client. By letting PHP determine when this is or doing all at once with a single ob_flush, it can batch the send inside http message efficiently. When you manually break it up at an arbitraty points, in this case every 10K you are breaking and enforcing at least one manual package transmit. The latency of this transport to the client is probably higher than the actually php buffer flushing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a web application (PHP) for my friend and have decided to use
I'm writing a PHP application that manages some LDAP entries. I have one page
I am writing a web application in php where users can upload their own
I'm writing an application in PHP 5. I want to delete some rows in
I'm writing an application in PHP, and I need to replace any word between
I am writing a PHP application that will have the ability to edit settings
I'm writing a php application and was wondering if it's a bad idea to
I am writing a new application in PHP which will be released to the
I'm currently writing a PHP application and drivers (classes) for the database engines. I
Background: Experienced PHP developer with a mostly *nix background. I'm writing a PHP application

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.