Calculating execution time in PHP

Calculating execution time in PHP

Calculating the execution time is very simple in PHP
using the time function we can get the script execution time
easily and exactly.

The below code will help to find execution time.


<?php
function current_time()
{
$time = microtime();
$time = explode(" ",$time);
$time = $time[1] + $time[0];
return $time;
}
$starttime = current_time();

/**************
Do your code here

********************/

$endtime = current_time();
$totaltime = ($endtime - $starttime);
echo "This page was created in ".$totaltime." seconds";
;?>

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.