Include overhead

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Antimon

    Include overhead

    Hi,

    I'm working on a new web application (php5.1 + postgresql) and i wanted
    to have seperated files for each class and use __autoload and i have
    everything split to classes now. This makes my pages need to include a
    lot of files each request. Do this a huge overhead? I mean shall i go
    for gigantic function definition scripts and include all of them at
    once?
    BTW, my classes are not too big, 4-5 methods and properties each, i
    thought having one function definition file might avoid including
    overhead but then php will need to interperate all that functions that
    i will not use.
    What shall i do?

    Thanks.

  • Andy Hassall

    #2
    Re: Include overhead

    On 10 Sep 2005 02:11:10 -0700, "Antimon" <antimon@gmail. com> wrote:
    [color=blue]
    >I'm working on a new web application (php5.1 + postgresql) and i wanted
    >to have seperated files for each class and use __autoload and i have
    >everything split to classes now. This makes my pages need to include a
    >lot of files each request. Do this a huge overhead? I mean shall i go
    >for gigantic function definition scripts and include all of them at
    >once?
    >BTW, my classes are not too big, 4-5 methods and properties each, i
    >thought having one function definition file might avoid including
    >overhead but then php will need to interperate all that functions that
    >i will not use.
    >What shall i do?[/color]

    You'd have to test and benchmark both approaches on your system, as it seems
    to me there are far too many unknown factors to be able to say one approach has
    a clear advantage over the other.

    Could this be premature optimisation? I'd be surprised if the absolute
    difference between either approach was significant compared with the runtime of
    the scripts, particularly since you're communicating with a database.

    Might it be best to keep it simple at this stage, i.e. not use autoload but
    bear the approach in mind for the future whilst you develop the more important
    parts of the code, and then try it out if the size of the included files
    appears to be causing a delay?

    You might want to look at something like APC which further reduces the cost of
    includes by caching the compiled code.

    --
    Andy Hassall :: andy@andyh.co.u k :: http://www.andyh.co.uk
    http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

    Comment

    • Colin McKinnon

      #3
      Re: Include overhead

      Antimon wrote:
      [color=blue]
      > to have seperated files for each class and use __autoload and i have[/color]
      <snip>[color=blue]
      > What shall i do?
      >[/color]

      Measure it for yourself.

      I suspect you would need to have a lot of classes to get a benefit from only
      a single include file - but then in the real world you're going to have to
      load a lot of stuff that you simply don't need - which may offset the
      savings you made by consolidating the classes (particularly of you are
      using a PHP accelerator).

      C.

      Comment

      Working...