Dorsey Posted September 18, 2003 Posted September 18, 2003 Is there any way to determine the execution times of scripts? I'd really like to "profile" my script before it gets out of control. In the past, I've used run-time profilers to determine where and how much time is spent in programs I've written, with the objective of determining if new algorithms are required, or if re-arranging the code can reduce runtime and/or lower response time. I've looked into the MySQL and PHP documents, and their respective forums, as well as TCH forums, but haven't found anything like what I want. These scripts will be run as cron jobs - is there something available along those lines to obtain the information I need? Or, is this whole concept a thing of the past? Dorsey Quote
surefire Posted September 18, 2003 Posted September 18, 2003 I have a script that you can put into a page that will tell you how fast it takes for the server to execute all the code. Anytime you want to see the run time, you just view the source code. Not sure if that's the same. Quote
Dorsey Posted September 21, 2003 Author Posted September 21, 2003 It's probably a start at what I'm looking for. If you don't mind, please send me a link, or show it in this forum. The script I wish to "profile" consists of outer and inner query loops. Within the inner loop, e-mail is generated, but not necessarily on each iteration. It would not be uncommon for the innermost code to execute millions of times. Other RDBMS will show their query execution plans for given SQL, but I'm not aware of this facility with MySQL. Evaluating a QEP can reveal how effective indices, key selections, and table organization actually are. Honestly, I don't have formal MySQL DBA training, so there may be something I'm not aware of. So, it's really this that I wish to evaluate, and any clues as to how to accomplish that will be appreciated. Thanks. Quote
surefire Posted September 21, 2003 Posted September 21, 2003 ><?php function get_microtime() { $mtime = microtime(); $mtime = explode(" ", $mtime); $mtime = doubleval($mtime[1]) + doubleval($mtime[0]); return ($mtime); } $time1 = get_microtime(); //all the stuff you want to time goes here $time2 = get_microtime(); $diff = abs($time2-$time1); ?> From PHP Developer's Cookbook Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.