On Saturday 01 August 2009 8:25:40 pm Clancy wrote: > Is anyone here interested in discussing programming strategy, or or know of > a discussion group which is interested in the subject? > > The sorts of questions I am interested in are: > > 1. I have a highly variable program which always shows the same page, but > which includes different modules to give different results. The various > modules call on different functions. Is it better to minimise memory by > including only the functions actually required, but increase the number of > files included, or to bundle all the functions into one file, thereby > reducing the number of files included but increasing the size in memory? That depends greatly on your usage patterns. Does your application make lots of "sideways" calls to integrate different modules, or is just "switch on a GET parameter, run this function, done"? If the latter, then lazy-loading just the one or two files you want is probably better. If the former, you'd need a lot of interesting logic to make lazy-loading work well enough to be justified. (I've been working on such a system for Drupal for the past year, and it's not easy to get right because there can be a fair bit of overhead.) If your application is heavily OOP then PHP supports dynamic autoloading of classes, which can greatly simplify your code logic but at the same time the autoload mechanism itself is not free either. The age of the computer matters, too. Modern hard drives are faster than they used to be, and more recent OS versions can do some fairly aggressive caching if the files you're reading all fit inside the OS cache somewhere in memory so you may not actually hit disk to "load" each of your files. > 2. As PHP is an interpreted program comments certainly increase the memory > requirements, and presumably they slow down the operation of the program. > Would stripping out the comments before uploading the production version > give any visible improvement in performance? I actually benchmarked that once. I had a reasonably large PHP file that was, in fact, over 50% docblocks. That's not even counting inline comments. While trying to find things to optimize, removing about 800 lines worth of comments (all of the docblocks) did, in fact, produce a noticeable performance difference. It was only barely noticeable, but it just barely registered as more than random sampling jitter. I actually concluded that if cutting the file *in half* was only just barely noticeable, then it really wasn't worth the effort. Just install an opcode cache. That will take care of most of your memory issues. :-) -- Larry Garfield larry@xxxxxxxxxxxxxxxx -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php