note 28843 modified in function.echo by kennyt
| From: | kennyt@php.net | Date: | Thu, 01 Jan 2004 06:11:20 +0000 |
| Subject: | note 28843 modified in function.echo by kennyt | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-62736@lists.php.net to get a copy of this message | ||
[Ed. Note: During normal execution, the buffer (where echo's arguments go) is not flushed
(sent) after each write to the buffer. To do that you'd need to use the flush() function, and
even that may not cause the data to be sent, depending on your web server.]
Echo is an i/o process and i/o processes are typically time consuming. For the longest time i have
been outputting content by echoing as i get the data to output. Therefore i might have hundreds of
echoes in my document. Recently, i have switched to concatenating all my string output together and
then just doing one echo at the end. This organizes the code more, and i do believe cuts down on a
bit of time. Likewise, i benchmark all my pages and echo seems to influence this as well. At the top
of the page i get the micro time, and at the end i figure out how long the page took to process.
With the old method of "echo as you go" the processing time seemed to be dependent on the
user's net connection as well as the servers processing speed. This was probably due to how
echo works and the sending of packets of info back and forth to the user. One an one script i was
getting .0004 secs on a cable modem, and a friend of mine in on dialup was getting .2 secs. Finally,
to test that echo is slow; I built strings of XML and XSLT and used the PHP sablotron functions to
do a transformation and return a new string. I then echoed the string. Before the echo, the process
time was around .025 seconds and .4 after the echo. So if you are big into getting the actual
processing time of your scripts, don't include echoes since they seem to be user dependent.
Note that this is just my experience and it could be a fluke.
--was--
Echo is an i/o process and i/o processes are typically time consuming. For the longest time i have
been outputting content by echoing as i get the data to output. Therefore i might have hundreds of
echoes in my document. Recently, i have switched to concatenating all my string output together and
then just doing one echo at the end. This organizes the code more, and i do believe cuts down on a
bit of time. Likewise, i benchmark all my pages and echo seems to influence this as well. At the top
of the page i get the micro time, and at the end i figure out how long the page took to process.
With the old method of "echo as you go" the processing time seemed to be dependent on the
user's net connection as well as the servers processing speed. This was probably due to how
echo works and the sending of packets of info back and forth to the user. One an one script i was
getting .0004 secs on a cable modem, and a friend of mine in on dialup was getting .2 secs. Finally,
to test that echo is slow; I built strings of XML and XSLT and used the PHP sablotron functions to
do a transformation and return a new string. I then echoed the string. Before the echo, the process
time was around .025 seconds and .4 after the echo. So if you are big into getting the actual
processing time of your scripts, don't include echoes since they seem to be user dependent.
Note that this is just my experience and it could be a fluke.
http://www.php.net/manual/en/function.echo.php