RE: [PHP] Classes and performance bottlenecks

From: Date: Tue, 14 Aug 2001 06:37:10 +0000
Subject: RE: [PHP] Classes and performance bottlenecks
Groups: php.general 
Request: Send a blank email to php-general+get-62577@lists.php.net to get a copy of this message
See, there's also a time needed for the server to read the included file - an extra effort for your hard disk. If you'd put everything in one file it would work for you faster, but, of course, less portable. Though, I don't understand why are your performance measures THAT different. Cheers, Maxim Maletsky -----Original Message----- From: Artyom Plouzhnikoff [mailto:artyompl@softhome.net] Sent: Tuesday, August 14, 2001 2:22 PM To: php-general@lists.php.net Subject: [PHP] Classes and performance bottlenecks I have a strange problem with PHP 4.0.4pl1 and above. It looks like including a file that contains classes can become a major performance bottleneck My machine is an Intel Pentium ]I[ 667Mhz, 128Mb RAM running RedHat Linux 7.1; I installed PHP as a DSO module. I used ab (Apache Benchmark) for benchmarking. The following application runs a very simple query and outputs the result: <?php $db = pg_pconnect("dbname=jokes user=foo password=xxxxxxxxx"); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <html> <head> <title>test</title> </head> <body> <?php $res = pg_exec($db, "SELECT * FROM j_jokes ORDER BY posted DESC LIMIT 10"); echo "<table>"; for ($i=0; $i<pg_numrows($res);$i++) { echo "<tr>"; $row = pg_fetch_row($res, $i); for ($c=0;$c<count($row);$c++) echo "<td>$row[$c]</td>"; echo "</tr>"; } echo "</table>"; ?> </body> </html> It can process up to 200 requests per second depending on the size of the dataset. Sometimes it can do even more than that. I didn't optimize Apache and PostgreSQL for performance. However, the following "application" <?php require_once("Smarty.class.php"); require_once("DB.php"); ?> can process about 25 requests per second. My applications use Smarty, Pear DB and my own classes from several include files. Thus, they can hardly handle 10 requests per second. I tried to benchmark them in many different ways and I figured out that *including* a class takes a lot of time. Using those classes doesn't seem to change anything dramatically. Is it an inherent problem of using classes with PHP or is there something I can do about it? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#62577) next »