mMsgs = array(); $this->mStart = microtime(true); } static public function instance() { if(self::$stInstance == NULL) { self::$stInstance = new performance_helper(); } return self::$stInstance; } public function start() { $this->mStart = microtime(true); } public function push($tag,$info = '',$start = NULL) { if($start == NULL) { $start = $this->mStart; $this->mStart = microtime(true); } if(empty($info)) { $msg = sprintf("%s:%.6f",$tag,microtime(true) - $start); } else { $msg = sprintf("%s:%.6f,info=",$tag,microtime(true) - $start); $msg = $msg.$info; } array_push($this->mMsgs,$msg); } public static function clear() { self::instance()->mMsgs = array(); } public static function format_log() { foreach(self::instance()->mMsgs as $val) { echo $val . "

"; } } } function perfor_start() { performance_helper::instance()->start(); } function perfor_end($tag,$info = '') { performance_helper::instance()->push($tag,$info); } function perfor_period($tag,$start,$info = '') { performance_helper::instance()->push($tag,$info,$start); }