in reply to Many prints of small string or one print of huge string?

Assuming that your script is going to be able to produce some output immediately, and then some more after some delay through DB access or similar?

Depending upon the type of formatting of your HTML, some (most?) browsers will be able to start to render the page from the partial output from the early prints therebye giving the user a feeling that things are happening. This can be advantagous.

If you save it all up and print it all in one go, it may result in a longer delay before the browser starts to render something, which may cause the perception of a slower site than they might otherwise have.

This effect is particularly noticable when rendering large volumes of data in tables. If the rows are sent in separate chunks--and if the sizes of the cells are predefined--then most browsers will be able to render the table in chunks, rather having to wait for the whole table to arrive before being able to render anything.

This is one of those cases were perceived performance is probably more important that absolute performance.


Examine what is said, not who speaks.
"But you should never overestimate the ingenuity of the sceptics to come up with a counter-argument." -Myles Allen
"Think for yourself!" - Abigail        "Time is a poor substitute for thought"--theorbtwo         "Efficiency is intelligent laziness." -David Dunham
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon
  • Comment on Re: Many prints of small string or one print of huge string?

Replies are listed 'Best First'.
Re^2: Many prints of small string or one print of huge string?
by dmitryrusak (Acolyte) on Dec 02, 2004 at 07:04 UTC
    Thanks duff and BrowserUK, I think i will go for "print small chunks" sulution even if it will give me the better abs. performance, because in my case the data is really a huge table (which probably could be rendered partially).