当前位置: 首页>>代码示例>>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;未经允许,请勿转载。