Programming Theory
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesProgramming Theory

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old November 20th, 2006, 07:46 PM
maxshooter maxshooter is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 1 maxshooter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Performance issues using classes in php?

Hi there, can anybody help me on these questions?

1. When a class is loaded, does it load every function into memory.?
2. Which one is best of the 2 examples given below, based on
a) Fast execution
b) low memory or resources required
c) overall performance (ie. fast execution and low resources consumption)
php Code:
Original - php Code
  1.  
  2. Example A:
  3. ===========
  4.  
  5. file: myclass.php
  6. -----------------
  7. clase myclass
  8. {
  9.     function xyz()
  10.     {
  11.         blah;
  12.         blah;
  13.         ..... and so on upto 100s of lines of code
  14.     }
  15.        function abc()
  16.        {
  17.          echo "hello world";
  18.        }
  19. }
  20.  
  21. Example B:
  22. ==========
  23.  
  24. file: myclass.php
  25. -----------------
  26.  
  27. clase myclass
  28. {
  29.     function xyz()
  30.     {
  31.       include(blah.php);
  32.     }
  33.        function abc()
  34.        {
  35.          echo "hello world";
  36.        }
  37. }
  38.  
  39. file: blah.php
  40. --------
  41. <?php      
  42.     blah;
  43.     blah;
  44.         ..... and so on upto 100s of lines of code
  45. ?>

As you've noticed in the above 2 examples that Class in A is having all the statements inside a function.
While Class in B is including a seperate file (dynamically).

It is obvious that they won't make much difference when function xyz is called, on the performance.

But what is the best way to implement a class when most of the time we have to call function abc() and rarely function xyz()?

Reply With Quote
  #2  
Old November 27th, 2006, 09:30 AM
lig's Avatar
lig lig is offline
"Forum Nazi"
Click here for more information.
 
Join Date: Apr 2007
Location: Jacksonville, Fl
Posts: 4,775 lig User rank is Private First Class (20 - 50 Reputation Level)lig User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 Days 13 h 47 m 18 sec
Reputation Power: 7
RE: Performance issues using classes in php?

purely performance wise - procedural is better (generally speaking)- faster, less memory and less overhead. But objects are much better (again generally speaking) for maintainability and reusability.

When an object is instantiated it's data and methods are placed in memory for each object. When a function file is included - all the functions are moved into memory - even the ones you don't use.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesProgramming Theory > Performance issues using classes in php?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek