Application of PHP to obtain script running time_PHP tutorial

WBOY
Release: 2016-07-13 10:28:05
Original
682 people have browsed it

header("content-type:text/html;charset=utf-8");

//microtime—Returns the current Unix timestamp and microseconds

 $oldtime = microtime(true);

echo "The running time of this script is:";

 $v=0;

 for ($i = 0; $i < 100; $i++) {

 $v++;

 }

 $newtime =microtime(true);

//Get the time difference

$runtime = $newtime-$oldtime;

//Convert the timestamp into a string - var_export outputs or returns the string representation of a variable

$runtime=var_export($runtime);

//Intercept the string substr_count to calculate the number of occurrences of the string

 $postion = substr_count($runtime, 'E');

 $runtime = substr($runtime,0,$postion-1);

//Convert string value to floatfloatval — Get the floating point value of the variable

 $runtime = floatval($runtime)/1000;

echo $runtime."seconds";

 ?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/814669.htmlTechArticleheader(content-type:text/html;charset=utf-8); //microtime returns the current Unix time Stamp and number of microseconds $oldtime = microtime(true); echo The time this script runs is:; $v=0; for ($i = 0;...
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!