Home > Backend Development > PHP Tutorial > Application of PHP to obtain script running time_PHP tutorial

Application of PHP to obtain script running time_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:28:05
Original
779 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;...
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template