Bug #18029: Echoing long strings :: long echo times over a number of characters

From: Date: Thu, 27 Jun 2002 23:43:03 +0000
Subject: Bug #18029: Echoing long strings :: long echo times over a number of characters
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-12275@lists.php.net to get a copy of this message
From:             wrestlecar@hotmail.com
Operating system: Linux
PHP version:      4.2.1
PHP Bug Type:     Performance problem
Bug description:  Echoing long strings :: long echo times over a number of characters

I have discovered a problem that is most likely related to PHP and the echo
statement, but it is possible that it is a server configuration issue as
well.

When echoing long strings, the server has no problem until it gets to a
certain window of characters, this ranges depending on the load of the
server but is usually around 15,000 characters. For example, take a look
at these page generation times for a custom script that was developed to
investigate this issue( the load average on the server was about the same
when all tests were taken). The times listed below are simply to echo one
string with the number of characters indicated.

Display Length: 14201 characters.
Display Output: 0.00199 seconds.

Display Length: 14251 characters.
Display Output: 0.00159 seconds.

Display Length: 14301 characters.
Display Output: 0.12694 seconds.

Display Length: 14401 characters.
Display Output: 0.13424 seconds.

Now, getting to the really awkward part. If the string is "exploded" by
linebreak, and then echoed in a loop line by line, the processing time is
roughly 4x FASTER than that of echoing the single statement, this has been
verified by another script I developed.

This behavior is not present on everyone's system, it has been tested on
several systems using the same script and this was the worse case, while
some other systems did display similar results.

Here is the test script that was used to identify the problem:

<?php
for( $i = 0; $i <= 20000; $i++)
{
   $example_output .= '1';
}

$microtime = explode(' ', microtime());
$startTime = $microtime[0] + $microtime[1];
echo $example_output;
$microtime = explode(' ', microtime());
$endTime = $microtime[0] + $microtime[1];
echo 'Display Length: ', strlen($example_output), ' characters.<br>';
echo 'Display Output: ', round($endTime - $startTime, 5), ' seconds.';
?>

In the script, simply replace the 20000 with whatever number you wish to
check.

Below are a few posts I made on forums inquiring about this issue, and may
provide some small details by the other users that I did not pick up on.

http://www.sitepointforums.com/showthread.php?threadid=65280
http://www.invisionboard.com/forums/index.php?s=&act=ST&f=7&t=12538

Unfortunately, since the server is not my own and is a shared server, I do
not have a list of the modules PHP was installed with, but here is some
information on the server.

Status: http://dragon.nocdns.com
PHPInfo: http://dragon.nocdns.com/phpinfo/

Thank you for your assistance.

-- 
Edit bug report at http://bugs.php.net/?id=18029&edit=1
-- 
Fixed in CVS:        http://bugs.php.net/fix.php?id=18029&r=fixedcvs
Fixed in release:    http://bugs.php.net/fix.php?id=18029&r=alreadyfixed
Need backtrace:      http://bugs.php.net/fix.php?id=18029&r=needtrace
Try newer version:   http://bugs.php.net/fix.php?id=18029&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=18029&r=support
Expected behavior:   http://bugs.php.net/fix.php?id=18029&r=notwrong
Not enough info:     http://bugs.php.net/fix.php?id=18029&r=notenoughinfo
Submitted twice:     http://bugs.php.net/fix.php?id=18029&r=submittedtwice
register_globals:    http://bugs.php.net/fix.php?id=18029&r=globals



Thread (4 messages)

« previous php.bugs (#12275) next »