예제 #1
0
 /**
  * Test singleton.
  */
 public function testGetInstance()
 {
     $object = \Sifo\Benchmark::getInstance();
     $this->assertTrue($object instanceof \Sifo\Benchmark);
     $singleton = \Sifo\Benchmark::getInstance();
     $this->assertEquals($object, $singleton);
 }
예제 #2
0
 public function build()
 {
     $this->setLayout('debug/debug.tpl');
     // Basic Debug data:
     $debug['controllers'] = \Sifo\Debug::get('controllers');
     $debug['benchmarks'] = \Sifo\Debug::get('benchmarks');
     $debug['elements'] = \Sifo\Debug::get('elements');
     $debug['times'] = \Sifo\Debug::get('times');
     $this->renderDebugModule($debug, 'basic_debug', 'debug/basic_debug.tpl');
     // Database debug.
     $debug['queries'] = \Sifo\Debug::get('queries');
     $debug['queries_errors'] = \Sifo\Debug::get('queries_errors');
     $debug['queries_duplicated'] = \Sifo\Debug::get('duplicated_queries');
     $this->assign('debug', $debug);
     $this->renderDebugModule($debug, 'database', 'debug/database.tpl');
     // Search debug.
     $debug['searches'] = \Sifo\Debug::get('searches');
     $this->assign('debug', $debug);
     $this->renderDebugModule($debug, 'search', 'debug/search.tpl');
     // Environment variables:
     $debug['session'] = $this->getSessionData();
     $debug['cookies'] = FilterCookieDebug::getCookiesArray();
     // Debug messages:
     $debug['log_messages'] = \Sifo\Debug::get('log_messages');
     $this->assign('log_messages', $debug['log_messages']);
     $this->renderDebugModule($debug, 'log_messages', 'debug/log_messages.tpl');
     // Summary debug:
     $debug['rebuild_all'] = $this->isRebuildAllActive();
     $debug['times']['total'] = \Sifo\Benchmark::getInstance()->timingCurrent();
     if (!isset($debug['times']['cache'])) {
         $debug['times']['cache'] = 0;
     }
     if (!isset($debug['times']['external'])) {
         $debug['times']['external'] = 0;
     }
     if (!isset($debug['times']['db_connections'])) {
         $debug['times']['db_connections'] = 0;
     }
     if (!isset($debug['times']['db_queries'])) {
         $debug['times']['db_queries'] = 0;
     }
     if (!isset($debug['times']['search'])) {
         $debug['times']['search'] = 0;
     }
     $debug['times']['scripts'] = $debug['times']['total'] - ($debug['times']['db_connections'] + $debug['times']['db_queries'] + $debug['times']['search'] + $debug['times']['cache'] + $debug['times']['external']);
     $debug['memory_usage'] = $this->getMemoryUsage();
     $this->finalRender($debug);
 }
예제 #3
0
파일: Mysql.php 프로젝트: ninodafonte/SIFO
 /**
  * Singleton static method.
  *
  * @param string $profile The database server to connect to.
  * @return Db
  */
 public static function getInstance($profile = 'default')
 {
     if (!isset(self::$instance[$profile])) {
         Benchmark::getInstance()->timingStart('db_connections');
         self::$instance[$profile] = new Mysql($profile);
         Benchmark::getInstance()->timingCurrentToRegistry('db_connections');
     }
     return self::$instance[$profile];
 }
예제 #4
0
파일: Mysql.php 프로젝트: ninodafonte/SIFO
 /**
  * Calls a pdo method.
  *
  * @param string $method A method in the pdo object.
  * @param array $arguments The array of arguments to pass to the method.
  * @return mixed
  */
 public function __call($method, $arguments)
 {
     Benchmark::getInstance()->timingStart('db_' . $method);
     $result = call_user_func_array(array($this->pdo, $method), $arguments);
     $query_time = Benchmark::getInstance()->timingCurrentToRegistry('db_' . $method);
     if ($arguments !== array()) {
         DebugMysql::setDebug($arguments[0], $query_time, $arguments[1], $result, $this->db_params);
     }
     return $result;
 }