Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Plugin_Benchmark extends Zend_Controller_Plugin_Abstract {
- protected $_routeStart;
- protected $_routeEnd;
- protected $_dispatchLoopStart;
- protected $_dispatchLoopEnd;
- protected $_dispatchStart;
- protected $_dispatchEnd;
- protected $_speedAgentStart;
- protected $_speedAgentEnd;
- public function __construct() {
- $this->_speedAgentStart = microtime();
- }
- public function generateSpeedReport() {
- $this->_speedAgentEnd = microtime();
- $route = $this->_routeEnd - $this->_routeStart;
- $dispatchLoop = $this->_dispatchLoopEnd - $this->_dispatchLoopStart;
- $dispatch = $this->_dispatchEnd - $this->_dispatchStart;
- $speedAgent = $this->_speedAgentEnd - $this->_speedAgentStart;
- $speedAgent = "<!-- \n Unit: Microseconds \n Routing: $route \n Dispatch : $dispatch \n Dispatch Loop: $dispatchLoop \n Total : $speedAgent \n !--> ";
- return $speedAgent;
- }
- public function routeStartup(Zend_Controller_Request_Abstract $request)
- {
- $this->_routeStart = microtime();
- }
- public function routeShutdown(Zend_Controller_Request_Abstract $request)
- {
- $this->_routeEnd = microtime();
- }
- public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
- {
- $this->_dispatchLoopStart = microtime();
- }
- public function preDispatch(Zend_Controller_Request_Abstract $request)
- {
- $this->_dispatchStart = microtime();
- }
- public function postDispatch(Zend_Controller_Request_Abstract $request)
- {
- $this->_dispatchEnd = microtime();
- }
- public function dispatchLoopShutdown()
- {
- $this->_dispatchLoopEnd = microtime();
- $this->getResponse()
- ->appendBody($this->generateSpeedReport() . $this->_order);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement