From: webmaster at maczsoftware dot com Operating system: RedHat Linux 8.0 PHP version: 4.3.2RC4 PHP Bug Type: Output Control Bug description: Performance of ob_start() is bad when lot of HTML data is printed afterwards
I'm having some pretty weird issues with ob_start() function. I have a merely complex script, which parses XML file (its functionality is located in own class, which is included from another php file). Because this script can output pretty much data, I'm buffering the output and then send it to browser gzipped. However, the execution time of my script is 23 seconds with large XML file, so I started to investigate possibilities of optimization. I thought - of course - that XML parsing was taking too long, but when I started to count seconds with getmicrotime() function, I found out that ob_start("ob_gzhandler") was taking 14 seconds of that 23! So I suppose this could be a bug in the PHP. I'm not saying that the script is too slow, 23 secs can be completely possible, but that calling getmicrotime() right before and right after ob_start() and getting 14 secs can't be right. All data is printed after ob_start() call, and at the end of the script ob_end_flush() is called. I have also tried using non-gzipped output, with pretty same processing time. The code which relates to this problem is below: Code: $before = getmicrotime(); ob_start("ob_gzhandler"); $after = getmicrotime(); // Here comes some XML parsing and printing some large text data // ... print "Time usage for ob_start: " . ($after - $before) . " seconds\n"; ob_end_flush(); // This is standard getmicrotime from php.net function getmicrotime() { list($usec, $sec) = explode(" ",microtime()); return ((float)$usec + (float)$sec); } --- PHP INFO: PHP 4.3.2RC4 (cli) (built: May 22 2003 16:30:41) Copyright (c) 1997-2003 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies Configure line: ./configure --with-mysql --with-apxs=/usr/local/apache/bin/apxs --with-gd --with-zlib-dir=/usr/local --enable-memory-limit -- Edit bug report at http://bugs.php.net/?id=23836&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=23836&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=23836&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=23836&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=23836&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=23836&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=23836&r=support Expected behavior: http://bugs.php.net/fix.php?id=23836&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=23836&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=23836&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=23836&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23836&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=23836&r=dst IIS Stability: http://bugs.php.net/fix.php?id=23836&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=23836&r=gnused