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?
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?
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.
would I be able to tell if I ran the script from my computer using XAMMP?
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);
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.