[PHP] RE: Print or Echo takes lots of time

2006-09-27 Thread Sancar Saran
Hi,

Thanks for supporting, because of the approaching to the problem, I don't want 
to change generate once echo once style.

And I found solution like this,
I split  variable into an array and generate loop for printing, mostly fix the 
problem. 

And more interesting, some times problem repeates himself. I believe this was 
connected to php memory performance.

Anyhow is there any information about optimal echo or print size ?

Regards

Sancar

On Wednesday 27 September 2006 01:22, Richard Lynch wrote:
 On Mon, September 25, 2006 7:11 am, Sancar Saran wrote:
  When I was check the performance of my system I found interesting
  resuts.
 
  My code stores html output into a variable. When page creation
  complete I
  printed out the variable.
 
  Problem was generation html code takes 0.5 second and just
  echo $strPage takes 2.0 or more second.
 
  my code structure was.
 
  $strPage = html yada dayda;
  ...
  $strPage.=  another html tags;
  ...
  $strPage.= getSqlDataAndCreateSomeHtmlCOde();
  ...
  end of page creation.
  Current Total execution time 0.5 seconds.
  print $strPage;
  Current Total execution time 2.5 seconds.
 
  $strPage carries entire html structure (for example equal of 100K html
  code);
 
  excluding the cookie and other kind of header transfers and error
  messages,
  there was no print or echo command was submitted.
 
  Is there any idea about this latency and any idea to find problem...

 You could try echo-ing it out in chunks instead of waiting until the
 very end.

 echo/print has to send the data out through the very narrow pipe to
 Apache - the browser

 If you send every little snippet one tiny piece at a time, you waste
 resources.

 If you wait until the end and send out some huge monster string, you
 waste resources.

 Find the balance if you can.

 Depends on your hardware/bandwidth exactly where optimum is.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Print or Echo takes lots of time

2006-09-26 Thread Colin Guthrie
Google Kreme wrote:
 On 25 Sep 2006, at 06:11 , Sancar Saran wrote:
 $strPage = html yada dayda;
 ...
 $strPage.=  another html tags;
 ...
 $strPage.= getSqlDataAndCreateSomeHtmlCOde();
 
 If this is generating hundred of K of HTML, use ' instead of 
 
 (yes, it's faster).

In this example tho', it is not the string processing that is taking up
the time. The $ expansion etc. will be done when building the string
$strPage, not at the echo stage which is where the OP is seeing the delay.

Col.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Print or Echo takes lots of time

2006-09-26 Thread Richard Lynch
On Tue, September 26, 2006 4:08 am, Colin Guthrie wrote:
 Google Kreme wrote:
 On 25 Sep 2006, at 06:11 , Sancar Saran wrote:
 $strPage = html yada dayda;
 ...
 $strPage.=  another html tags;
 ...
 $strPage.= getSqlDataAndCreateSomeHtmlCOde();

 If this is generating hundred of K of HTML, use ' instead of 

 (yes, it's faster).

 In this example tho', it is not the string processing that is taking
 up
 the time. The $ expansion etc. will be done when building the string
 $strPage, not at the echo stage which is where the OP is seeing the
 delay.

Plus it's faster in such a marginal sense that you'd have to be
doing zillions in a very tight loop to measure it.

Benchmark it for yourself and see.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Print or Echo takes lots of time

2006-09-25 Thread Colin Guthrie
Sancar Saran wrote:
 Hi,
 
 When I was check the performance of my system I found interesting resuts.
 
 My code stores html output into a variable. When page creation complete I 
 printed out the variable.
 
 Problem was generation html code takes 0.5 second and just 
 echo $strPage takes 2.0 or more second.

I read a while ago that it is more efficient to echo as you go rather
than store up a large variable with the content in it.

You may want to investigate output buffering instead as 9 times in 10
the sames results of using a big variable can be achieved.

It does seem odd none the less tho' that it takes so long.

Col

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php