+ Reply to Thread
Results 1 to 5 of 5

Thread: How do you tell how much a resources a script uses?

  1. #1
    diabolo's Avatar
    diabolo is offline Community Advocate diabolo is on a distinguished road
    Join Date
    Nov 2007
    Location
    Jersey Shore
    Posts
    1,683

    How do you tell how much a resources a script uses?

    I have a script that creates files for a gallery and it write to these files every time the script runs.

    How do I tell how much resources the script is using?

  2. #2
    Twinkie is offline Banned Twinkie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Ft. Lauderdale, Florida
    Posts
    1,389

    Re: How do you tell how much a resources a script uses?

    The easiest way to do this is to write to a file the time that the script starts and the time that it ends, then you can experiment in how to make your PHP scripts more efficient. The resource usage monitor you were probably thinking about would need to be run on the server.

  3. #3
    diabolo's Avatar
    diabolo is offline Community Advocate diabolo is on a distinguished road
    Join Date
    Nov 2007
    Location
    Jersey Shore
    Posts
    1,683

    Re: How do you tell how much a resources a script uses?

    would I be able to tell if I ran the script from my computer using XAMMP?

  4. #4
    Twinkie is offline Banned Twinkie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Ft. Lauderdale, Florida
    Posts
    1,389

    Re: How do you tell how much a resources a script uses?

    Yes, you can open task manager and see how much memory/cpu usage spikes up when you run the script. Any other measurement but timing is relative to the servers capabilities, as you would not want to worry about the resource usage of a huge script that doesn't add to the load time. The timing is really all that matters. Here is a nice script that should work for you:

    PHP Code:
    //At the start of the script.
    $filename "timings.log";
    if (!
    file_exists($filename)) {
        
    touch($filename);
    }
    $timings fopen($filename,"a");
    fwrite($timings,date("g:i:s:u a")."\n\r");

    //PHP body...

    //At the end of the script
    fwrite($timings,date("g:i:s:u a")."\n\r\n\r");
    fclose($timings); 

  5. #5
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: How do you tell how much a resources a script uses?

    Also take a look at memory_get_usage, memory_get_peak_usage and getrusage. You can use Zend profiler or XDEBUG with XAMPP to profile your script and get timing information.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread

Similar Threads

  1. [OFF] selling some hot script 500 credits each
    By neteater in forum The Marketplace
    Replies: 8
    Last Post: 03-24-2009, 09:08 PM
  2. Help simplifying a php script to lower server resources
    By brunoais in forum Programming Help
    Replies: 4
    Last Post: 01-05-2009, 04:16 PM
  3. Access to 300+ PHP scripts (2500 credits)
    By jonathanyaniv in forum The Marketplace
    Replies: 11
    Last Post: 06-03-2008, 10:58 PM
  4. Replies: 8
    Last Post: 12-03-2007, 04:12 PM
  5. Server UP time Script
    By dharmil in forum Scripts & 3rd Party Apps
    Replies: 2
    Last Post: 04-03-2006, 04:39 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
x10hosting free hosting for the masses
dedicated servers