SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 29 of 29
  1. #26
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    What is detele?

  2. #27
    SitePoint Guru risoknop's Avatar
    Join Date
    Feb 2008
    Location
    end($world)
    Posts
    834
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I bet you have too many databse queries (for example make sure you are not quering the databse inside foreach loops or recursive functions... rather use more complex join query that will get you all data at once). That is the most usual reason why PHP sites are slow.

    Objects are little bit more heavy than arrays for example but the difference is really small. It ought to have no (visible) impact on the site performance.

  3. #28
    SitePoint Enthusiast
    Join Date
    Nov 2007
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Cups View Post
    What is detele?
    delete button on your keyboard. backspace is a space which is backward.

  4. #29
    SitePoint Addict
    Join Date
    Apr 2007
    Posts
    300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Vali View Post
    I noticed that my OOP site was 24 times slower than my normal sites.

    Turns out, all those function calls for objects (have __get / __set / standard functions) slow stuff down quite a bit.

    Old way:
    - I would have $data = db row
    - and access it with $data['foo']
    - DB work would make up ~75% of the page build time.

    OOP way:
    - have an object $data
    - have a for loop to populate the $data object ( $data->foo ) from the db select.
    - and then another function call to get the property value ( $data->foo ).
    - and since i'm a lazy typer, I have __get / __set for those...
    - DB work would make up ~25% of the page build time (same sql time as before, but more loops/ifs/stuff slowing things down).

    All this is WAY slower than the old way...

    For a "simple" page that would display some data from the database (2 selects and 4 loops, 2 get / 2 echo), I ended up having the 2 selects, plus the 4 loops, plus 500+ function calls, + some more IFs/Loops in my objects to set the data correctly.

    Problem is, once you get used to OOP, and find out that it's easier to maintain the code that way, you can't go back...

    I would be interested to see how others solved the performance problem, on shared servers (developing on WAMP where I can install anything), since everyone keeps saying that there is only "a slight overhead in some of these features, but they are extremely small."
    This simply means your oop technique is badly in need of optimization.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •