gusucode.com > 同城苏州黄页系统php源码程序 > lib/runtime.class.php
<? if( !class_exists('Smarty') ) include_once($root_path."lib/smarty/Smarty.class.php"); class runtime extends Smarty { var $timeList =array(); function init_runtime() { $this->timeList[0]=array('caption'=>'开始','now'=>$this->Mt(),'total'=>0,'near'=>0); return $this->out_runtime(); } function runtime() { return $this->init_runtime(); } function &Mt() { $arr=explode(" ",microtime()); return (float)$arr[1]+(float)$arr[0]; } function run_time($caption='') { $now=$this->Mt(); $lastTime=end($this->timeList); $this->timeList[]=array( 'caption' =>$caption, 'now' =>$now, 'total' =>$now-$this->timeList[0]['now'], 'near' =>$now-$lastTime['now'] ); return $this->out_runtime(); } function out_runtime() { $thisTime=end($this->timeList); return "【".( (!empty($thisTime['caption']))?$thisTime['caption']:(count($this->timeList)-1) )."】 总用时:".round($thisTime['total'],5)."秒/距上次".round($thisTime['near'],5)."秒<br>\r\n"; } } ?>