Results 1 to 11 of 11
  1. #1
    Full Member
    Join Date
    January 18th, 2005
    Posts
    396
    PHP size question
    What is the size range of your PHP programs - I ask to see if I am asking for problems when I combine two modules into my index.php program doubling its size - my combined program will be in the range of 30K and 1000 lines

    Charles

  2. #2
    .
    Join Date
    January 18th, 2005
    Posts
    2,973
    How long is a piece of string? It all depends. What is the program doing?

    I think you're saying that the script filesize is 30Kbytes, and that there are about 1,000 lines? That's might be reasonable; but it's excessive if the program isn't doing very much; and it's very terse if the program is doing a whole lot.

    I assume that you are using "include" files (and functions) to organize and modularize your code? If not, you should absolutely try to do so.

    Most of my script files are in the range of 80 to 150 lines of code (up to 200+ lines after extensive commenting), and I've got about a dozen active files right now (ignoring version variations).

    Much of my work starts with "specifics" (e.g. creating separate scripts to import a single ShareASale datafeed from a local file, and another to check for updates and download updated feeds) but then I try to generalize and streamline (so that a single script will process many different kinds of datafeeds from several networks).

    When I'm "finished" with a complete system to update and import datafeeds from 5+ networks, I expect that I'll have about 2,000 to 3,000 lines of commented code, split across about a dozen separate files. That doesn't include a bunch of other functionality.

  3. #3
    Visual Artist & ABW Ambassador lostdeviant's Avatar
    Join Date
    September 7th, 2007
    Location
    Cuautitlán, Edo. de México
    Posts
    1,725
    The problem isn't the size of the script. The problem is how much load is put on the server.

  4. #4
    Comfortably Numb John Powell's Avatar
    Join Date
    October 17th, 2005
    Location
    Bayou Country, LA
    Posts
    3,432
    The problem isn't the size of the script. The problem is how much load is put on the server.
    I agree here. There are some online sites where you can test the length of time it takes your script to run. Some will benchmark the page load time. I can never remember where those things are or I would give you a link.


  5. #5
    ABW Ambassador 2busy's Avatar
    Join Date
    January 17th, 2005
    Location
    Tropical Mountaintop
    Posts
    5,636
    A good place for a little test script is at and they have a lot of other useful stuff.

    The snippet that checks a php load time the last one on the list at that page.
    Last edited by Greg Rice; May 18th, 2009 at 05:21 PM. Reason: Something wrong with the links on that site.

  6. #6
    Visual Artist & ABW Ambassador lostdeviant's Avatar
    Join Date
    September 7th, 2007
    Location
    Cuautitlán, Edo. de México
    Posts
    1,725
    While you don't really know how much load is on the server, you can get a good idea if you get memory limit errors or the page takes a long time to load.

    If you use a mysql database table, do "explain" on each of your script's queries in phpmyadmin to make sure your table's indexes are being used. This is a mistake of both newbies and programmers of many years. Just because your mysql table has an index, it doesn't mean that the table is being used!
    Of course only do a query when you need to. Don't repeat queries in a loop if you can just run them once before a loop, only get the fields (and rows) you actually need to display instead of all of them, etc.
    I really enjoy periodically reviewing and improving my scripts, so perhaps every month or two a script gets a good revision. On Friday I caught a query that only needed to be run some of the time; It was happening every time that script ran... oops. I quickly added an IF statement to check a variable to see if it was needed

    If your content won't be changing frequently, set up menu or page caching to further reduce load.
    .
    Disclaimer: I'm still a newbie programmer of about a year, so I might be wrong :-)

  7. #7
    .
    Join Date
    January 18th, 2005
    Posts
    2,973
    > "While you don't really know how much load is on the server...." <

    Actually, with some VPS accounts, you can watch the server load in real time. See the partial screen-capture of my account, below. I can see that while my SAS-import script is running, the server was using 44% to 47% of allocated CPU resources.
    Attached Images Attached Images

  8. #8
    Visual Artist & ABW Ambassador lostdeviant's Avatar
    Join Date
    September 7th, 2007
    Location
    Cuautitlán, Edo. de México
    Posts
    1,725
    Quote Originally Posted by markwelch
    > "While you don't really know how much load is on the server...." <

    Actually, with some VPS accounts, you can watch the server load in real time. See the partial screen-capture of my account, below. I can see that while my SAS-import script is running, the server was using 44% to 47% of allocated CPU resources.
    sorry, I meant that for the shared hosting accounts most of us sign up for. Most shared hosts give no statistics on server load, while others might give you % of memory and/or % of CPU...

    Of course you CAN see how long a mysql query takes in PHP myadmin, but often the main factor is the size of the table and indexes (bigger table = bigger index = longer query), so in that case I want to make sure that the index used is as small as possible.

  9. #9
    ABW Veteran Mr. Sal's Avatar
    Join Date
    January 18th, 2005
    Posts
    6,795
    Thumbs down
    Quote Originally Posted by 2busy
    A good place for a little test script is at and they have a lot of other useful stuff.

    The snippet that checks a php load time the last one on the list at that page.
    That site looks like it's just a "Made For Adsense" site, there is no code there...

    Description
    The code
    Get the code
    Download the file to your computer: Click here to get the file
    I tried a few links there, and they all land on another "Made For Adsense" page with more fake links, to the so called "Get the code" link...
    Last edited by Greg Rice; May 18th, 2009 at 05:22 PM. Reason: Removed URL

  10. #10
    .
    Join Date
    January 18th, 2005
    Posts
    2,973
    Ditto - the link posted by 2busy just leads to an endless maze of links, all falsely promising access to code but each simply redirecting to another made-for-AdSense page.

    Did somebody hijack 2busy's account?

  11. #11
    ABW Ambassador Greg Rice's Avatar
    Join Date
    January 18th, 2005
    Location
    Ohio
    Posts
    4,889
    Yeah, something weird with those links so I removed the URL/link until 2busy can see what is happening.
    Greg Rice Affiliate Program Management
    www.gocmc.com info(AT)gocmc.com | 330-259-1223

    Join us! - MiNeeds.com | DiscountCandleShop/CheeseSupply | Feng Shui Plaza

  12. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. PHP question - include(file.php) with variables
    By teezone in forum Programming / Datafeeds / Tools
    Replies: 8
    Last Post: September 4th, 2009, 04:54 PM
  2. Shareasale Video Size Question
    By SunshineTricia in forum ShareASale - SAS
    Replies: 3
    Last Post: September 8th, 2008, 03:32 PM
  3. Size Appeal question??
    By purplebear in forum Commission Junction - CJ
    Replies: 5
    Last Post: July 31st, 2006, 05:57 PM
  4. Help Please - .php Question
    By ~Michelle in forum Programming / Datafeeds / Tools
    Replies: 12
    Last Post: March 18th, 2004, 02:52 PM

Posting Permissions

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