The class is very simple. It mainly uses several functions, the array list function list(), the string is divided into the array function explode(), and the timestamp and microsecond number microtime() are obtained. The code is as follows:
Copy the code The code is as follows:
class runTime {
private $starTime;//Start time
private $stopTime;//End time
private function getMicTime(){
$mictime=microtime();//Get Timestamp and microseconds
list($usec,$sec)=explode(" ",$mictime);//Split the microseconds into arrays and convert them into variables for processing
return (float)$usec+(float)$ sec;//Force the converted data to be processed with floating point points
}
public function star(){//Get the start time
$this->starTime=$this->getMicTime();
}
public function stop(){//Get the end time
$this->stopTime=$this->getMicTime();
}
public function spent(){//Calculate the program duration
return round($this-> ;stopTime-$this->starTime)*1000;//Get the number of milliseconds
}
}
//Example
$time=new runTime();
$time->star();
for ($i =1;$i<=1000;$i++){
echo("a");
}
$time->stop();
echo $time->spent();
?>
The above introduces the class of PHP test program running time that is not a valid win32 application, including the content of a non-valid win32 application. I hope it will be helpful to friends who are interested in PHP tutorials.