You are here: Re: Performance impact of "require"ing lots of source? « PHP Programming Language « IT news, forums, messages
Re: Performance impact of "require"ing lots of source?

Posted by lister on 03/28/07 07:30

On Mar 27, 7:06 pm, "ZeldorBlat" <zeldorb...@gmail.com> wrote:
> On Mar 27, 2:17 pm, "lister" <listerofsme...@hotmail.com> wrote:
>
>
>
>
>
> > Hi all,
>
> > I have a fairly diverse range of data that I want to cache in the
> > session rather than pulling it from the database on every page
> > refresh.
>
> > The problem is is that it seems that PHP requires the class
> > definitions available on EVERY page, as it unserialises everything
> > even if it's not going to be used.
>
> > This has put me in the worrying situation of having to "require"
> > pretty much every class definition in my project on every page, and
> > I'm concerned about the performance impact this is going to have due
> > to PHP having to parse reams of code every time.
>
> > Are there any elegant ways around this? Am I worrying over nothing?
>
> > Cheers,
> > Lister
>
> Are you experiencing some specific performance problem? Or are you
> just worrying before you actually have a reason to? :) Honestly, I
> don't think it will cause any problems.
>
> This was recently discussed in another thread, but you should make use
> of __autoload():
>
> <http://www.php.net/autoload>
>
> Besides the fact that it will only load classes as necessary, it will
> also save you from having all those require()'s at the top of your
> page.- Hide quoted text -
>
> - Show quoted text -

Thanks for the replies both.

No, I'm not seeing a performance problem as such - still writing the
site so proper performance testing is a long way off. I was just
trying to write defensively and was getting a bit concerned about the
amount of code that was having to be parsed on every page.
You're probably correct and it's not something I should be worrying
about yet.

> If your project is that disorganized, then you will have to do it. My
> projects typically have dozens of classes, and most pages require only
> 3-4. A few might require a couple of more.

Well yeah, typically my pages only need 3 or 4 too, but I wanted to
cache a whole lot of other info. I may have to forget this idea and
just cache stuff that is local to the current page/s.

Thanks again.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация