Calculating SQL query processing All I want do to is simply get the result of how long (in seconds) the PHP takes to process the SQL query. Am I on a right track? Is my code correct to get the result I want?

&lt;?php
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("test3", $con);

    $start = microtime(TRUE);
    $result = mysql_query("SELECT * FROM `test`
    ORDER BY `test`.`test2` DESC
    LIMIT 0,100");


echo "&lt;table border='1'&gt;
&lt;tr&gt;
&lt;th&gt;ID&lt;/th&gt;
&lt;th&gt;test1&lt;/th&gt;
&lt;th&gt;test2&lt;/th&gt;
&lt;th&gt;test3&lt;/th&gt;
&lt;th&gt;test4&lt;/th&gt;
&lt;/tr&gt;";

while($row = mysql_fetch_array($result))
  {
  echo "&lt;tr&gt;";
  echo "&lt;td&gt;" . $row['ID'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['test1'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['test2'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['test3'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['test4'] . "&lt;/td&gt;";
  echo "&lt;/tr&gt;";
  }
echo "&lt;/table&gt;";

$end = microtime(TRUE);

$sqlTime = $end - $start;


mysql_close($con);
echo $sqlTime
?&gt;
Yes, microtime is designed to be used for this. The PHP documentation mentions this use case for microtime().
Consider putting this into a loop and print out the average result: if the measured time is too small, you can't provide a reliable estimation.
Concerning the MySQL request: you should switch to mysqli or PDO.