How long does the PHP tutorial calculate the time code for the page
function test ()
{
List ($a, $b) = Explode ("", Microtime ());
return (float) $a + (float) $b;
}
$a =test ();
echo $a;
$time = sprintf ("%.12f", (double) test ()-$a); Method Two
Function Ss_timing_start ($name = ' default ') {
global $ss _timing_start_times;
$ss _timing_start_times[$name] = explode (', microtime ());
}
Function ss_timing_stop ($name = ' default ') {
global $ss _timing_stop_times ;
$ss _timing_stop_times[$name] = explode (', microtime ());
}
Function ss_timing_current ($name = ' default ') {
global $ss _timing_start_ Times, $ss _timing_stop_times;
if (!isset ($ss _timing_start_times[$name)) {
return 0;
}
if (!isset ($ss _timing_stop_times[$name)) {
$stop _time = Explode (", microtime ());
}
else {
$stop _time = $ss _timing_ stop_times[$name];
}
//Do the big numbers The Sgt ones aren't ' t lost
$current = $stop _time[1]-$ss _timing_start_times[$name][1];
$current + + $stop _time[0]-$ss _timing_start_times[$name][0];
return $current;
}
Ss_timing_start ();
/**
Below is the code for your page
/
require_once ' index.php tutorial ';//index.php is the page to test execution time
/*
Page code end
//
Ss_timing_stop ()//Method three
Class Timer
{
var $starttime = 0;
var $stoptime = 0;
var $timespent = 0;
function Start () {
$this->starttime = Microtime ();}
function Stop () {
$this->stoptime = Microtime ();}
function spent () {
if ($this->timespent) {
return $this->timespent;
else {
$startmicro = substr ($this->starttime,0,10);
$startsecond = substr ($this->starttime,11,10);
$stopmicro = substr ($this->stoptime,0,10);
$stops Tutorial Econd = substr ($this->stoptime,11,10);
$start = Doubleval ($startmicro) + $startsecond;
$stop = Doubleval ($stopmicro) + $stops tutorial Econd;
$this->timespent = $stop-$start;
Return substr ($this->timespent,0,8). Seconds ";
}
}//End Function spent ();
}//end class timer;
Example
$timer = new Timer;
$timer->start ();
/*
Your code is here.
*/
$timer->stop ();
echo "Execute this script altogether". $timer->spent ();