I have a script that is running slowly and I was wondering how I could time it and see which fixes improve the speed. Is there some sort of a PHP timer?
Update: Thought I should clarify… The script that is running slowly is my mailing list script that sends an email to everyone on the list. So I am looping through an array of subscribers and sending them an email one by one. It’s so slow that I thought it would be interesting to see how long it took to iterate though the array. So I’m looking for a quick and easy way to test that.
I ended up using a timer class I found similar to this one: http://forum.codecall.net/php-tutorials/4254-php-timer-class.html
I just started a timer at the beginning of my loop and logged the duration at the end of each iteration. Found out, on average, it was taking between 3 and 4 seconds per email! Five minutes per email blast is a little too much. Time to refactor…