當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Profiler::stop方法代碼示例

本文整理匯總了PHP中Profiler::stop方法的典型用法代碼示例。如果您正苦於以下問題:PHP Profiler::stop方法的具體用法?PHP Profiler::stop怎麽用?PHP Profiler::stop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Profiler的用法示例。


在下文中一共展示了Profiler::stop方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: delete

	/**
	 * Overload Sprig::delete() to update child articles
	 * to become children of the uncategorized subcategory
	 */
	public function delete(Database_Query_Builder_Delete $query = NULL) {
		Kohana::$log->add(Kohana::DEBUG, 'Beginning subcategory deletion for subcategory_id='.$this->id);
		if (Kohana::$profiling === TRUE)
		{
			$benchmark = Profiler::start('blog', 'delete subcategory');
		}

		$uncategorized = Sprig::factory('subcategory', array('name'=>'uncategorized'))->load();

		// Modify category IDs for all child articles
		try
		{
			DB::update('articles')->value('subcategory_id', $uncategorized->id)
				->where('subcategory_id', '=', $this->id)->execute();
		}
		catch (Database_Exception $e)
		{
			Kohana::$log->add(Kohana::ERROR, 'Exception occured while modifying deleted subcategory\'s articles. '.$e->getMessage());
			return $this;
		}

		if (isset($benchmark))
		{
			Profiler::stop($benchmark);
		}

		return parent::delete($query);
	}
開發者ID:nagius,項目名稱:kohana-blog,代碼行數:32,代碼來源:subcategory.php

示例2: render

 public function render()
 {
     $token = Profiler::start(__CLASS__, __FUNCTION__);
     $r = parent::render();
     Profiler::stop($token);
     return $r;
 }
開發者ID:ragchuck,項目名稱:ra-Log,代碼行數:7,代碼來源:layout.php

示例3: measure_runtime

 /**
  * @param string $function
  * @param mixed  $parameters ....
  */
 public function measure_runtime()
 {
     $arr = func_get_args();
     $fn = array_shift($arr);
     if (is_array($fn)) {
         $cl_name = get_class($fn[0]);
         $fn_name = $fn[1];
     } elseif (0 === strpos(strtolower($fn), 'self::')) {
         $fn_name = explode('::', $fn);
         $cl_name = get_class();
         $fn_name = $fn_name[1];
     } elseif (0 === strpos(strtolower($fn), 'parent::')) {
         $fn_name = explode('::', $fn);
         $cl_name = get_parent_class(get_class());
         $fn_name = $fn_name[1];
     } else {
         $fn_name = explode('::', $fn);
         $cl_name = $fn_name[0];
         $fn_name = $fn_name[1];
     }
     $time = microtime(true);
     if (Kohana::$profiling === TRUE) {
         $benchmark = Profiler::start($cl_name, $fn_name);
     }
     $response = call_user_func_array($fn, $arr);
     $time = (microtime(true) - $time) * 1000;
     if (isset($benchmark)) {
         // Stop the benchmark
         Profiler::stop($benchmark);
     }
     ORM::factory('Rest_Metric')->millisec($cl_name . '/' . $fn_name, ceil($time));
     return $response;
 }
開發者ID:gianebao,項目名稱:kohana-rest,代碼行數:37,代碼來源:Metrics.php

示例4: load

 /**
  * Returns the translation table for a given language.
  *
  *     // Get all defined Spanish messages
  *     $messages = I18n::load('es-es');
  * 
  * После генерации таблицы происходит создание Javascript файла с таблицей
  * перевода для загружаемого языка.
  *
  * @param   string  $lang   language to load
  * @return  array
  */
 public static function load($lang)
 {
     $table = parent::load($lang);
     $filename = Kohana::$cache_dir . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, array('i18n', NULL)) . $lang . '.js';
     if (!file_exists($filename) or file_exists($filename) and time() - filemtime($filename) > Date::DAY) {
         if (Kohana::$profiling === TRUE and class_exists('Profiler', FALSE)) {
             // Start a new benchmark
             $benchmark = Profiler::start('i18n', 'Generate file for lang - ' . $lang);
         }
         try {
             // Create the log file
             file_put_contents($filename, '// Auto generated i18n lang file for lang ' . $lang . ". Created on " . date('Y-m-d H:i:s') . "\n");
             file_put_contents($filename, 'cms.addTranslation(' . json_encode($table) . ');', FILE_APPEND);
             // Allow anyone to write to log files
             chmod($filename, 0777);
         } catch (Exception $e) {
             // do something
         }
         if (isset($benchmark)) {
             // Stop the benchmark
             Profiler::stop($benchmark);
         }
     }
     return $table;
 }
開發者ID:ortodesign,項目名稱:cms,代碼行數:37,代碼來源:i18n.php

示例5: __construct

 public function __construct($id = NULL)
 {
     Kohana::$profiling === TRUE && ($bm = Profiler::start('ORM', __FUNCTION__));
     parent::__construct($id);
     $this->after_initialize();
     isset($bm) && Profiler::stop($bm);
 }
開發者ID:alshabalin,項目名稱:kohana-advanced-orm,代碼行數:7,代碼來源:ORM.php

示例6: query

 public function query($type, $sql, $as_object = FALSE, array $params = NULL)
 {
     $this->_connection or $this->connect();
     if (JsonApiApplication::$profiling) {
         $benchmark = Profiler::start("Database ({$this->_instance})", $sql);
     }
     try {
         $result = $this->_connection->query($sql);
     } catch (Exception $e) {
         if (isset($benchmark)) {
             Profiler::delete($benchmark);
         }
         throw new Database_Exception(':error [ :query ]', array(':error' => $e->getMessage(), ':query' => $sql), $e->getCode());
     }
     if (isset($benchmark)) {
         Profiler::stop($benchmark);
     }
     $this->last_query = $sql;
     if ($type === Database::SELECT) {
         if ($as_object === FALSE) {
             $result->setFetchMode(PDO::FETCH_ASSOC);
         } elseif (is_string($as_object)) {
             $result->setFetchMode(PDO::FETCH_CLASS, $as_object, $params);
         } else {
             $result->setFetchMode(PDO::FETCH_CLASS, 'stdClass');
         }
         $result = $result->fetchAll();
         return new Database_Result_Cached($result, $sql, $as_object, $params);
     } elseif ($type === Database::INSERT) {
         return array($this->_connection->lastInsertId(), $result->rowCount());
     } else {
         return $result->rowCount();
     }
 }
開發者ID:benshez,項目名稱:DreamWeddingCeremonies,代碼行數:34,代碼來源:PDO.php

示例7: get_smarty

 public static function get_smarty()
 {
     if (isset(self::$smarty)) {
         return self::$smarty;
     }
     $token = Kohana::$profiling ? Profiler::start('smarty', 'load smarty') : false;
     $config = Kohana::config('smarty');
     try {
         include $config->smarty_class_file;
     } catch (Exception $e) {
         throw new Kohana_Exception('Could not load Smarty class file');
     }
     $smarty = new Smarty();
     // deal with initial config
     $smarty->php_handling = constant($config->php_handling);
     // deal with main config
     foreach ($config->smarty_config as $key => $value) {
         $smarty->{$key} = $value;
     }
     // check we can write to the compiled templates directory
     if (!is_writeable($smarty->compile_dir)) {
         self::create_dir($smarty->compile_dir, 'Smarty compiled template');
     }
     // if smarty caching is enabled, check we can write to the cache directory
     if ($smarty->caching && !is_writeable($smarty->cache_dir)) {
         self::create_dir($smarty->cache_dir, 'Smarty cache');
     }
     self::$smarty = $smarty;
     $token ? Profiler::stop($token) : null;
     return $smarty;
 }
開發者ID:pg7812,項目名稱:kohana-module-smarty,代碼行數:31,代碼來源:smarty.php

示例8: stopQuery

 public function stopQuery()
 {
     if ($this->benchmark) {
         \Profiler::stop($this->benchmark);
         $this->benchmark = null;
     }
 }
開發者ID:aspendigital,項目名稱:fuel-doctrine2,代碼行數:7,代碼來源:Logger.php

示例9: stop_zend_profiler

/**
 * Stop Zend Profiler
 */
function stop_zend_profiler()
{
    include APPPATH . 'config' . DIRECTORY_SEPARATOR . 'database.php';
    if ($db[$active_group]['Zend_Db_Profiler_Firebug']) {
        Profiler::stop();
    }
}
開發者ID:sabril-2t,項目名稱:Open-Ad-Server,代碼行數:10,代碼來源:zend.php

示例10: execute

 public function execute($db = 'default')
 {
     if (!is_object($db)) {
         // Get the database instance
         $db = Database::instance($db);
     }
     // Import the SQL locally
     $sql = $this->_sql;
     if (!empty($this->_values)) {
         // Quote all of the values
         $values = array_map(array($db, 'quote'), $this->_values);
         // Replace the values in the SQL
         $sql = strtr($sql, $values);
     }
     if ($this->profile === TRUE) {
         // Start profiling this query
         $token = Profiler::start('database (' . (string) $db . ')', $sql);
     }
     // Load the result
     $result = $db->query($this->_type, $sql);
     if (isset($token)) {
         // Stop profiling
         Profiler::stop($token);
     }
     return $result;
 }
開發者ID:ukd1,項目名稱:kohana,代碼行數:26,代碼來源:query.php

示例11: __construct

 public function __construct($file = null, array $data = null)
 {
     $token = Kohana::$profiling ? Profiler::start('renderer', 'new kohana view') : false;
     $this->_config = Kohana::config('render');
     parent::__construct($file, $data);
     $token ? Profiler::stop($token) : null;
 }
開發者ID:pg7812,項目名稱:kohana-module-smarty,代碼行數:7,代碼來源:view.php

示例12: run

 /**
  * Run script
  *
  */
 public function run()
 {
     try {
         $content = $this->_factory->getModel('crawlerModel')->crawl($this->_args);
         //array of data to render
         $result = array();
         $sortArr = array();
         foreach ($content as $key => $data) {
             $time = $data['time'];
             Profiler::start($key);
             $renderData = TagCounterHelper::count($data['content'], 'img');
             Profiler::stop($key);
             $time += Profiler::fetch($key);
             array_push($result, array($key, (int) $renderData['img'], $time));
             array_push($sortArr, $renderData['img']);
         }
         array_multisort($sortArr, SORT_DESC, $result);
         if (!empty($result)) {
             array_unshift($result, $this->_tableHeaders);
         }
         ViewHelper::getRenderer()->process(array('grid' => $result));
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }
開發者ID:alex311982,項目名稱:crawler,代碼行數:29,代碼來源:crawler.php

示例13: execute

 /**
  * Processes the request, executing the controller. Before the routed action
  * is run, the before() method will be called, which allows the controller
  * to overload the action based on the request parameters. After the action
  * is run, the after() method will be called, for post-processing.
  *
  * By default, the output from the controller is captured and returned, and
  * no headers are sent.
  *
  * @return  $this
  */
 public function execute()
 {
     // Create the class prefix
     $prefix = 'controller_';
     if (!empty($this->directory)) {
         // Add the directory name to the class prefix
         $prefix .= str_replace(array('\\', '/'), '_', trim($this->directory, '/')) . '_';
     }
     if (Kohana::$profiling === TRUE) {
         // Start benchmarking
         $benchmark = Profiler::start('Requests', $this->uri);
     }
     try {
         // Load the controller using reflection
         $class = new ReflectionClass($prefix . $this->controller);
         if ($class->isAbstract()) {
             throw new Kohana_Exception('Cannot create instances of abstract :controller', array(':controller' => $prefix . $this->controller));
         }
         // Create a new instance of the controller
         $controller = $class->newInstance($this);
         // Execute the "before action" method
         $class->getMethod('before')->invoke($controller);
         // Determine the action to use
         $action = empty($this->action) ? Route::$default_action : $this->action;
         // Ensure the action exists, and use __call() if it doesn't
         if ($class->hasMethod('action_' . $action)) {
             // Execute the main action with the parameters
             $class->getMethod('action_' . $action)->invokeArgs($controller, $this->_params);
         } else {
             $class->getMethod('__call')->invokeArgs($controller, array($action, $this->_params));
         }
         // Execute the "after action" method
         $class->getMethod('after')->invoke($controller);
     } catch (Exception $e) {
         if (isset($benchmark)) {
             // Delete the benchmark, it is invalid
             Profiler::delete($benchmark);
         }
         if ($e instanceof ReflectionException) {
             // Reflection will throw exceptions for missing classes or actions
             $this->status = 404;
         } else {
             // All other exceptions are PHP/server errors
             $this->status = 500;
         }
         // Re-throw the exception
         throw $e;
     }
     if (isset($benchmark)) {
         // Stop the benchmark
         Profiler::stop($benchmark);
     }
     return $this;
 }
開發者ID:bluehawk,項目名稱:kohanut-core,代碼行數:65,代碼來源:request.php

示例14: testServerDataFromProfilerToProfile

 public function testServerDataFromProfilerToProfile()
 {
     $serverData = array('foo' => 'bar');
     // Currently, $_SERVER data is hardcoded empty array, @see Profiler::stop:r256
     $profiler = new Profiler();
     $profiler->start();
     $profile = $profiler->stop();
     // Override $_SERVER for tests
     $profile->setServerData($serverData);
     $this->assertEquals($serverData, $profile->getServerData());
 }
開發者ID:link0,項目名稱:profiler,代碼行數:11,代碼來源:ProfilerTest.php

示例15: friends

 public function friends()
 {
     if (Kohana::$profiling === TRUE) {
         $benchmark = Profiler::start('Kohana_Facebook', 'facebook->api(/me/friends)');
     }
     $result = $this->_facebook->api('/me/friends');
     if (isset($benchmark)) {
         // Stop the benchmark
         Profiler::stop($benchmark);
     }
     return $result['data'];
 }
開發者ID:Netshops-Commerce-GmbH,項目名稱:Kohana-Facebook-Auth,代碼行數:12,代碼來源:facebook.php


注:本文中的Profiler::stop方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。