WolfRage Posted July 12, 2009 Share Posted July 12, 2009 I want to know if I am using some OOP techniques, and I include some extra classes. These classes are rarely used but dynamically activate based on set parameters. Will the inclusion of the scripts slow down the time for PHP to process a request or will it simply ignore the files unless the classes are initialized. How does the difference in time compare to not including the files at all? Quote Link to comment https://forums.phpfreaks.com/topic/165714-will-including-classes-with-out-initializing-them-slow-down-processing-time/ Share on other sites More sharing options...
Daniel0 Posted July 12, 2009 Share Posted July 12, 2009 It's not just a yes/no question. Performance depends on a lot of things. Using a lot of require_once()'s will have a negative performance impact for instance. Quote Link to comment https://forums.phpfreaks.com/topic/165714-will-including-classes-with-out-initializing-them-slow-down-processing-time/#findComment-874152 Share on other sites More sharing options...
WolfRage Posted July 12, 2009 Author Share Posted July 12, 2009 OK. I am using include_once() does this have a larger impact because PHP has to check to see if the script has already been called? How much of a hit? I was attempting shorten my code as much as possible, but I think using switch statements or if statements to include the classes may provide better performance. Perhaps I should set up some timing scenarios and figure this out on my own. But I am wondering if some one has already done the work? Quote Link to comment https://forums.phpfreaks.com/topic/165714-will-including-classes-with-out-initializing-them-slow-down-processing-time/#findComment-874161 Share on other sites More sharing options...
Daniel0 Posted July 12, 2009 Share Posted July 12, 2009 You can implement a namespace autoloader like you'll find in Zend Framework 1.8+ (or just use the one they provide). Quote Link to comment https://forums.phpfreaks.com/topic/165714-will-including-classes-with-out-initializing-them-slow-down-processing-time/#findComment-874163 Share on other sites More sharing options...
WolfRage Posted July 12, 2009 Author Share Posted July 12, 2009 Thanks for the autoloader, I think this is exactly what I am looking for. I have also found several other good articles on different performance topics since posting the question. But I guess my one question that is unanswered is: I have heard that PHP jumps around in the code executing as is needed and leaving out the rest, that is why several classes can be included yet still execute with lightening speed; is this true? Quote Link to comment https://forums.phpfreaks.com/topic/165714-will-including-classes-with-out-initializing-them-slow-down-processing-time/#findComment-874178 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.