SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot Offspring2099's Avatar
    Join Date
    May 2005
    Location
    Los Angeles, CA
    Posts
    182
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Slow down using OOP

    Hello,
    Iíve been experiencing a major slow down while using OOP in php5. One class places data into a DATA array. Very simple. And second class takes that data puts it into a html table and makes a nice html page. What I have noticed is that a slow down happens if I have more then 10 or so items in my DATA array, also it only happens when the SECOND class is called, which loops through DATA array and puts the data into table. My main server cranks everything through pretty efficiently, but the experimental server has slow downs up to 1 minute. BTW Iím using XAMPP 1.4.13 for windows for the experimental server with PHP 5.0.4 and MySQL 4.1.11. Does anyone have any ideas? Anything would be helpful. Thanks.

  2. #2
    SitePoint Evangelist ClickHeRe's Avatar
    Join Date
    Mar 2005
    Location
    Ottawa, Canada
    Posts
    580
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    would you mind showing a bit of code to see if you aren't doing something wrong that might hog the server resources ?

  3. #3
    SitePoint Zealot Offspring2099's Avatar
    Join Date
    May 2005
    Location
    Los Angeles, CA
    Posts
    182
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Where the slow down happens, it is as simple as:

    $mainString .= HTMLheaderstuff;

    while($row = current($data)) {
    //get the data from $row and put it into table
    //keep adding table to $mainString
    next($data)
    }

    return $mainString;


    There is truly nothing to it. A few javascript calls in the beginning. But just like you said, I think its a server issue. Not the code. If you have any ideas I will be have to investigate them. This a real problem for me, because I have to wait in "minutes" everytime I work on these files. Thank you for your time.

  4. #4
    SitePoint Wizard
    Join Date
    Aug 2004
    Location
    California
    Posts
    1,672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What is slow? The:

    while($row = current($data)) {

    Or:

    //get the data from $row and put it into table
    //keep adding table to $mainString

    Or:

    next($data)
    Christopher

  5. #5
    SitePoint Zealot Offspring2099's Avatar
    Join Date
    May 2005
    Location
    Los Angeles, CA
    Posts
    182
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The slow down seems to happen when the second class is looking through the DATA array with if statements. Even though the search through the DATA array is N^2. It is very simple and only takes 2 seconds on 'good' server. It takes up to 2 second per row on the 'bad' server, thus taking it 1 minute to load.

    EDIT: Note that the 'good' server has a slower CPU. Also on the 'bad' server, I'm monitoring the memory usage and it doesn't really go up or down. At first I thought it was a memory issue.

  6. #6
    SitePoint Zealot Offspring2099's Avatar
    Join Date
    May 2005
    Location
    Los Angeles, CA
    Posts
    182
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I uninstalled my apache and php, but left my sql on. Then installed the lastest version of WAMP. And everything runs smoothly. Wierd.


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
  •