Heim  >  Artikel  >  Backend-Entwicklung  >  看过google的搜索吗搜索共花了多少时间这里有一个类可以统计脚本执行时间的。_PHP教程

看过google的搜索吗搜索共花了多少时间这里有一个类可以统计脚本执行时间的。_PHP教程

WBOY
WBOYOriginal
2016-07-13 17:29:06915Durchsuche

addmarker("Start"); } // end function start() // 在脚本的结束处调用这个函数 function stop() { // 请看后面的addmarker函数 $this->addmarker("Stop"); } // end function stop() // 这个函数用来在脚本执行时增加一个标记 // 需要一个用来描述的名字 function addmarker($name) { // 调用 jointime() 函数并将microtime() 的返回值传递过去 $markertime = $this->jointime(microtime()); // $ae 得到当前数组的大小,也就是当前的插入位置 // currently in the $points array $ae = count($this->points); // 在数组中存储timestamp 和说明 $this->points[$ae][0] = $markertime; $this->points[$ae][1] = $name; } // end function addmarker() // 这个函数会处理从microtime() 返回的字串 function jointime($mtime) { // 分解字串 $timeparts = explode(" ",$mtime); // 连接两个字串,并去除小数部分的0 $finaltime = $timeparts[1].substr($timeparts[0],1); // 返回连接后的字串 return $finaltime; } // end function jointime() // 这个函数简单的显示从开始到结束所需要的时间 function showtime() { echo bcsub($this->points[count($this->points)-1][0],$this->points[0][0],6); } // end function showtime() // 这个函数显示所有的在脚本运行过程中收集到的信息 function debug() { echo "Script execution debug information:"; echo " "; // 这个表格有3列 Marker name, Timestamp, difference echo "MarkerTimeDiff "; // 第一行是没有运行时间差的 echo " "; echo "".$this->points[0][1].""; echo "".$this->points[0][0].""; echo "- "; echo " "; // 从数组的元素1开始循环显示,0已经在第一行显示过了 for ($i = 1; $i points);$i++) { echo " "; echo "".$this->points[$i][1].""; echo "".$this->points[$i][0].""; echo ""; // 显示上下两行的时间差 echo bcsub($this->points[$i][0],$this->points[$i-1][0],6); echo ""; echo " "; } echo ""; } // end function debug() } // end class PHP_timer ?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/531715.htmlTechArticleaddmarker(Start); } // end function start() // 在脚本的结束处调用这个函数 function stop() { // 请看后面的addmarker函数 $this->addmarker(Stop); } // end function...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn