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
  #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"
Codewalkers Demi-God (4500 - 4999 posts)
 
Join Date: Apr 2007
Location: Jacksonville, Fl
Posts: 4,719 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 4 m 29 sec
Reputation Power: 6
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!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five &quot;checkpoints&quot; for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

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





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway