You can use microtime
as the start and end of your PHP code:
<?php
$time_start = microtime(true);
sleep(1);
$time_end = microtime(true);
$time = $time_end - $time_start;
echo "Process Time: {$time}";
// Process Time: 1.0000340938568
?>
As of PHP 5.4.0, there is no need to get start time at the beginning,
the $_SERVER
superglobal array already has it:
<?php
sleep(1);
$time = microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"];
echo "Process Time: {$time}";
// Process Time: 1.0061590671539
?>