国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

php計算頁面執行了多長時間代碼

2024-05-04 21:58:32
字體:
來源:轉載
供稿:網友
  1. function test()          
  2. {          
  3.     list($a,$b)= explode(" ",microtime());          
  4.     return (float)$a+(float)$b;          
  5. }      
  6. //代碼如下: 
  7. $a=test();         
  8. echo $a;         
  9. $time    = sprintf("%.12f",(double)test()-$a);  
  10. //方法二,代碼如下: 
  11. function ss_timing_start ($name = 'default') {  
  12.       global $ss_timing_start_times;  
  13.       $ss_timing_start_times[$name] = explode(' ', microtime());  
  14. }  
  15. function ss_timing_stop ($name = 'default') {  
  16.       global $ss_timing_stop_times;  
  17.       $ss_timing_stop_times[$name] = explode(' ', microtime());  
  18. }  
  19. function ss_timing_current ($name = 'default') {  
  20.       global $ss_timing_start_times$ss_timing_stop_times;  
  21.       if (!isset($ss_timing_start_times[$name])) {  
  22.           return 0;  
  23.       }  
  24.       if (!isset($ss_timing_stop_times[$name])) {  
  25.           $stop_time = explode(' ', microtime());  
  26.       }  
  27.       else {  
  28.           $stop_time = $ss_timing_stop_times[$name];  
  29.       }  
  30.       // do the big numbers first so the small ones aren't lost  
  31.       $current = $stop_time[1] - $ss_timing_start_times[$name][1];  
  32.       $current += $stop_time[0] - $ss_timing_start_times[$name][0];  
  33.       return $current;  
  34. //開源代碼Vevb.com 
  35. ss_timing_start();  
  36. /**  
  37. 以下是你的頁面的代碼  
  38. */  
  39. require_once    'index.php教程'//index.php是要測試執行時間的頁面  
  40. /*  
  41. 頁面代碼結束  
  42. */  
  43. ss_timing_stop(); 
  44. //方法三,代碼如下: 
  45. class timer 
  46. {  
  47. var $starttime = 0; 
  48. var $stoptime = 0; 
  49. var $timespent = 0; 
  50. function start(){ 
  51. $this->starttime = microtime();} 
  52. function stop(){ 
  53. $this->stoptime = microtime();} 
  54. function spent(){ 
  55. if ($this->timespent) { 
  56. return $this->timespent; 
  57. else { 
  58. $startmicro = substr($this->starttime,0,10); 
  59. $startsecond = substr($this->starttime,11,10); 
  60. $stopmicro  = substr($this->stoptime,0,10); 
  61. $stops教程econd = substr($this->stoptime,11,10); 
  62. $start = doubleval($startmicro) + $startsecond
  63. $stop = doubleval($stopmicro) + $stops教程econd; 
  64. $this->timespent = $stop - $start
  65. return substr($this->timespent,0,8)."秒"
  66. }// end function spent(); 
  67. }//end class timer; 
  68. //例子 
  69. $timer = new timer; 
  70. $timer->start(); 
  71. /* 
  72. 你的代碼放在此處 
  73. */ 
  74. $timer->stop(); 
  75. echo "執行本script共".$timer->spent(); 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 运城市| 林甸县| 县级市| 福安市| 雅江县| 平南县| 鸡东县| 普格县| 波密县| 峨山| 淅川县| 怀化市| 正宁县| 巴林左旗| 屯门区| 镇江市| 错那县| 台江县| 刚察县| 深圳市| 焉耆| 芒康县| 土默特左旗| 锦州市| 台湾省| 儋州市| 札达县| 香格里拉县| 若尔盖县| 成都市| 南乐县| 曲沃县| 安吉县| 吉木萨尔县| 新津县| 广汉市| 泗阳县| 福安市| 闻喜县| 龙江县| 云和县|