What is the best way to see how long it takes for your PHP script to run?
I was thinking something like this:
$start_time = time(); //this at the beginning
$end_time = time(); //this at the end
echo = $end_time-$start_time;
But how can I make it into something that is readable to me and make sense to me?
If you want any further granularity to your timing than seconds, you’ll need to use
microtime()(Return current Unix timestamp with microseconds)** Below was added later **
As far as formatting this result further:
Well, depending on what you’re doing, you typically don’t have scripts going past a minute. You definitely shouldn’t have anything exceeding an hour. (If you do, you need to ask yourself what you are doing with your life)
With that in mind, all you need is simple calculations:
(This isn’t tested, and it could potentially be optimized, but should start you in the right direction)