Re: Classes and performance bottlenecks

From: Date: Wed, 15 Aug 2001 02:39:31 +0000
Subject: Re: Classes and performance bottlenecks
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-62747@lists.php.net to get a copy of this message
> <?php > require_once("Smarty.class.php"); > require_once("DB.php"); > ?> I used to think that require_once() was quite slow, and that doing your own: if (!defined('smarty_class')){ define('smarty_class'); class Smarty{ ... } } was way more better. It might depend on how *MANY* things you've already included... So, you can paste that exact same code into your files, and it goes fast? Don't Smary and DB do a lot of includes of their own? And is DB using pconnect? If not, *THAT* will be your biggest bottle-neck of all. Change that, and ab again. Or, put it this way -- Move your pg_connect() into a connect.inc, and require() that, and ab the joke page. Your pg_connect() should be in a separate file not in your web-tree anyway. > 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? Bottom line: Loading in files from the disk on a busy server with multiple users (IE, 200 different web-sites' index.htm files to clog up the cache) can get very slow unless your file cache can hold them all. Zend cache will ameliorate this to a great extent -- as the file is loaded once into RAM and left there. -- WARNING richard@zend.com address is an endangered species -- Use ceo@l-i-e.com Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm

« previous php.general (#62747) next »