On Sun, Aug 02, 2009 at 11:25:40AM +1000, 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?

My advice would be to only load the modules you need, no matter how
convoluted the logic you must use to do that. A lot of PHP programmers
are very sloppy about memory usage, falling back on the cache argument,
etc. But there's no reason to use more memory than you have to.

However, there is an issue if all these modules are scattered about
everywhere. You also have to look at the overhead on the server when
it's having to open 15 files for every page displayed. That's silly as

So it's a trade-off. If you have the latter problem, I'd probably opt to
put everything in one or a few files. In my opinion, disk thrashing on a
busy internet server is worse than gobbling up more memory. That disk
thrashing is likely to have a negative effect on all the other users of
that server.

> 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 bow to those who have profiled this, as far as performance goes.
However, remember, you have to *maintain* this code. In a trade-off
between performance and maintainability, I'd opt for maintainability.
You'll thank yourself in the future.


Paul M. Foster

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to