# PHP exec time
Web @ 21 October 2008
Sometimes, I need to optimize pieces of code, especially mysql query execution time. But how to check if some piece of code is faster than other?
I use PHP function
Thats how it looks like:
$code_starts = microtime(true);
…
<some code>
…
$code_ends = microtime(true);
$execution_time = $code_ends – $code_starts;
echo "Done in: ".$execution_time." s";
…
<some code>
…
$code_ends = microtime(true);
$execution_time = $code_ends – $code_starts;
echo "Done in: ".$execution_time." s";
Have a nice bottleneck finding!
