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


PHP Profiler類代碼示例

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


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

示例1: WebLauncher

 /**
  * Launches a test module for web inspection of results
  * @param string $module
  * @return boolean
  */
 function WebLauncher($module)
 {
     jf::$ErrorHandler->UnsetErrorHandler();
     $this->LoadFramework();
     self::$TestSuite = new \PHPUnit_Framework_TestSuite();
     self::$TestFiles[] = $this->ModuleFile($module);
     self::$TestSuite->addTestFile(self::$TestFiles[0]);
     $result = new \PHPUnit_Framework_TestResult();
     $listener = new TestListener();
     $result->addListener($listener);
     $Profiler = new Profiler();
     if (function_exists("xdebug_start_code_coverage")) {
         xdebug_start_code_coverage();
     }
     self::$TestSuite->run($result);
     if (function_exists("xdebug_start_code_coverage")) {
         $Coverage = xdebug_get_code_coverage();
     } else {
         $Coverage = null;
     }
     $Profiler->Stop();
     $listener->Finish();
     $this->OutputResult($result, $Profiler, $Coverage);
     return true;
 }
開發者ID:michalkoczwara,項目名稱:WebGoatPHP,代碼行數:30,代碼來源:test.php

示例2: admin_page_bottom

 static function admin_page_bottom($theme)
 {
     if (Session::instance()->get("profiler", false)) {
         $profiler = new Profiler();
         $profiler->render();
     }
 }
開發者ID:Juuro,項目名稱:Dreamapp-Website,代碼行數:7,代碼來源:core_theme.php

示例3: testSqlNumRows

 public function testSqlNumRows()
 {
     // Simulate three queries
     $this->profiler->sqlProfiler("some query");
     $this->profiler->sqlProfiler("some query");
     $this->profiler->sqlProfiler("some query");
     // Do not stop the profilers, jump right to the assertions
     // How evil!
     self::assertEquals(3, $this->profiler->getNumQueries());
 }
開發者ID:apexstudios,項目名稱:yamwlib,代碼行數:10,代碼來源:ProfilerTest.php

示例4: admin_page_bottom

 static function admin_page_bottom($theme)
 {
     $session = Session::instance();
     if ($session->get("profiler", false)) {
         $profiler = new Profiler();
         $profiler->render();
     }
     if ($session->get("l10n_mode", false)) {
         return L10n_Client_Controller::l10n_form();
     }
 }
開發者ID:scarygary,項目名稱:gallery3,代碼行數:11,代碼來源:gallery_theme.php

示例5: 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

示例6: 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

示例7: query

 public function query($type, $sql, $as_object)
 {
     if (isset($this->_config['connection']) === true) {
         $this->database = $this->_config['connection']['database'];
     }
     $result = parent::query($type, $sql, false);
     if ($type === Database::SELECT) {
         $table = array();
         if (count($result) > 0) {
             foreach ($result->current() as $key => $data) {
                 $table[0][] = $key;
             }
             $result->rewind();
             foreach ($result as $row) {
                 $table[] = $row;
             }
             $result->rewind();
         } else {
             $table[] = array('No', 'rows');
         }
         $group = Profiler::groups();
         $group = Profiler::total($group['database (default)'][$sql][0]);
         FirePHP::getInstance()->table($this->database . ' : (' . number_format($group[0], 6) . 's) ' . $sql, $table);
     } elseif ($type === Database::INSERT) {
         FirePHP::getInstance()->info($this->database . ' : Insert id: ' . $result[0] . ' Affected rows: ' . $result[1]);
     } else {
         FirePHP::getInstance()->info($this->database . ' : Affected rows: ' . $result[0]);
     }
     return $result;
 }
開發者ID:pedrosland,項目名稱:kohana-firephp,代碼行數:30,代碼來源:mysql.php

示例8: 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

示例9: __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

示例10: cache

 /**
  * Cache data.
  *
  * @return  void
  */
 public static function cache()
 {
     if (!Profiler::show('cache')) {
         return;
     }
     $queries = Cache::$queries;
     $table = new Profiler_Table();
     $table->add_column();
     $table->add_column('kp-column kp-data');
     $table->add_column('kp-column kp-data');
     $table->add_column('kp-column kp-data');
     $table->add_row(array('Cache', 'Gets', 'Sets', 'Deletes'), 'kp-title', 'background-color: #E0FFE0');
     text::alternate();
     $total_gets = $total_sets = $total_deletes = 0;
     $total_requests = array();
     foreach ($queries as $type => $requests) {
         foreach ($requests as $query) {
             if (!isset($total_requests[$query])) {
                 $total_requests[$query] = array('gets' => 0, 'sets' => 0, 'deletes' => 0);
             }
             $total_requests[$query][$type]++;
         }
     }
     foreach ($total_requests as $query => $types) {
         $data = array($query, $types['gets'], $types['sets'], $types['deletes']);
         $class = text::alternate('', 'kp-altrow');
         $table->add_row($data, $class);
         $total_gets += $types['gets'];
         $total_sets += $types['sets'];
         $total_deletes += $types['deletes'];
     }
     $data = array('Total: ' . count($total_requests), $total_gets, $total_sets, $total_deletes);
     $table->add_row($data, 'kp-totalrow');
     Profiler::add($table);
 }
開發者ID:anqqa,項目名稱:Anqh,代碼行數:40,代碼來源:MY_Profiler.php

示例11: stopQuery

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

示例12: 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

示例13: action_change

 public function action_change()
 {
     //トークンの生成
     $this->action_csrf();
     //バリデーション定義
     $val = Validation::forge();
     $val->add('password', '「現在のパスワード」')->add_rule('required')->add_rule('min_length', 8)->add_rule('max_length', 12);
     $val->add('newpassword', '「新しいパスワード」または、「(新)パスワード再入力」')->add_rule('required')->add_rule('min_length', 8)->add_rule('max_length', 12);
     $this->action_category();
     if (Input::post()) {
         if (Security::check_token()) {
             if ($val->run()) {
                 $username = Auth::get_screen_name();
                 //現在のパスワード
                 $old_password = Input::post('password');
                 //新しいパスワード
                 $new_password = Input::post('newpassword');
                 //パスワードを変更するメソッド
                 Auth::change_password($old_password, $new_password, $username);
                 $this->message = 'パスワードが変更されました。';
                 $view = View::forge('changepass/ChangePass', $this->data);
                 $view->set_global('message', $this->message, false);
                 $view->set_global('error', $this->error, false);
             } else {
                 $this->error = $val->error();
                 $view = View::forge('changepass/ChangePass', $this->data);
                 $view->set_global('message', $this->message, false);
                 $view->set_global('error', $this->error, false);
             }
         } else {
             Profiler::mark('CSRF攻撃');
         }
     }
     return $view;
 }
開發者ID:nihonLoomba,項目名稱:noteshare-,代碼行數:35,代碼來源:changepass.php

示例14: execute

 /**
  * Main execution point
  *
  * @param null|string $code Confirmation code passed to the page
  * @throws PermissionsError
  * @throws ReadOnlyError
  * @throws UserNotLoggedIn
  */
 function execute($code)
 {
     // Ignore things like master queries/connections on GET requests.
     // It's very convenient to just allow formless link usage.
     $trxProfiler = Profiler::instance()->getTransactionProfiler();
     $this->setHeaders();
     $this->checkReadOnly();
     $this->checkPermissions();
     // This could also let someone check the current email address, so
     // require both permissions.
     if (!$this->getUser()->isAllowed('viewmyprivateinfo')) {
         throw new PermissionsError('viewmyprivateinfo');
     }
     if ($code === null || $code === '') {
         $this->requireLogin('confirmemail_needlogin');
         if (Sanitizer::validateEmail($this->getUser()->getEmail())) {
             $this->showRequestForm();
         } else {
             $this->getOutput()->addWikiMsg('confirmemail_noemail');
         }
     } else {
         $old = $trxProfiler->setSilenced(true);
         $this->attemptConfirm($code);
         $trxProfiler->setSilenced($old);
     }
 }
開發者ID:paladox,項目名稱:mediawiki,代碼行數:34,代碼來源:SpecialConfirmemail.php

示例15: __construct

 /**
  * The Symphony constructor initialises the class variables of Symphony.
  * It will set the DateTime settings, define new date constants and initialise
  * the correct Language for the currently logged in Author. If magic quotes
  * are enabled, Symphony will sanitize the `$_SERVER`, `$_COOKIE`,
  * `$_GET` and `$_POST` arrays. The constructor loads in
  * the initial Configuration values from the `CONFIG` file
  */
 protected function __construct()
 {
     self::$Profiler = Profiler::instance();
     self::$Profiler->sample('Engine Initialisation');
     if (get_magic_quotes_gpc()) {
         General::cleanArray($_SERVER);
         General::cleanArray($_COOKIE);
         General::cleanArray($_GET);
         General::cleanArray($_POST);
     }
     $this->initialiseConfiguration();
     define_safe('__SYM_DATE_FORMAT__', self::Configuration()->get('date_format', 'region'));
     define_safe('__SYM_TIME_FORMAT__', self::Configuration()->get('time_format', 'region'));
     define_safe('__SYM_DATETIME_FORMAT__', __SYM_DATE_FORMAT__ . self::Configuration()->get('datetime_separator', 'region') . __SYM_TIME_FORMAT__);
     DateTimeObj::setSettings(self::Configuration()->get('region'));
     // Initialize language management
     Lang::initialize();
     $this->initialiseLog();
     GenericExceptionHandler::initialise(self::Log());
     GenericErrorHandler::initialise(self::Log());
     $this->initialiseDatabase();
     $this->initialiseExtensionManager();
     $this->initialiseCookie();
     // If the user is not a logged in Author, turn off the verbose error messages.
     if (!self::isLoggedIn() && is_null($this->Author)) {
         GenericExceptionHandler::$enabled = false;
     }
     // Set system language
     Lang::set(self::$Configuration->get('lang', 'symphony'));
 }
開發者ID:readona,項目名稱:symphonyno5,代碼行數:38,代碼來源:class.symphony.php


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