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 function clear() { $this->mMsgs = []; } public function format_log() { $content = ''; foreach($this->mMsgs as $val) { $content .= $val . "\n"; } return $content; } } function perfor_start() { performance_helper::instance()->start(); } function perfor_log() { return performance_helper::instance()->format_log(); } function perfor_end($tag,$info = '') { performance_helper::instance()->push($tag,$info); } function perfor_period($tag,$start,$info = '') { performance_helper::instance()->push($tag,$info,$start); } function perfor_clear() { performance_helper::instance()->clear(); }