Home > Backend Development > PHP Tutorial > Not a valid win32 application PHP test program runtime class

Not a valid win32 application PHP test program runtime class

WBOY
Release: 2016-07-29 08:47:55
Original
1216 people have browsed it

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.

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template