How To Time A Database Query In PHP And MySQL

$time_start=0;

function startTimer(){ global $time_start; $time_start = microtime(true);}

function printTimer(){ global $time_start; $time_end = microtime(true); $time = $time_end - $time_start; echo sprintf(%f, $time); echo ' Seconds';}