程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> 看過google的搜索嗎搜索共花了多少時間這裡有一個類可以統計腳本執行時間的。

看過google的搜索嗎搜索共花了多少時間這裡有一個類可以統計腳本執行時間的。

編輯:關於PHP編程

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 < count($this->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 ?>

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved