#23836 [Opn->Fbk]: Performance of ob_start() is bad when lot of HTML data is printed afterwards

From: Date: Tue, 27 May 2003 22:26:24 +0000
Subject: #23836 [Opn->Fbk]: Performance of ob_start() is bad when lot of HTML data is printed afterwards
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-40535@lists.php.net to get a copy of this message
ID: 23836 Updated by: sniper@php.net Reported By: webmaster at maczsoftware dot com -Status: Open +Status: Feedback Bug Type: Output Control Operating System: RedHat Linux 8.0 PHP Version: 4.3.2RC4 New Comment: Please provide a complete but short and self-contained example script which we can try ourselves. Previous Comments: ------------------------------------------------------------------------ [2003-05-27 12:02:17] webmaster at maczsoftware dot com 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 this bug report at http://bugs.php.net/?id=23836&edit=1

« previous php.bugs (#40535) next »