当前位置: 首页>>代码示例>>PHP>>正文


PHP Debugger::timer方法代码示例

本文整理汇总了PHP中Tracy\Debugger::timer方法的典型用法代码示例。如果您正苦于以下问题:PHP Debugger::timer方法的具体用法?PHP Debugger::timer怎么用?PHP Debugger::timer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tracy\Debugger的用法示例。


在下文中一共展示了Debugger::timer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: stopQuery

 public function stopQuery()
 {
     if ($this->explainRunning) {
         return;
     }
     $keys = array_keys($this->queries);
     $key = end($keys);
     $this->queries[$key][self::TIME] = Debugger::timer('doctrine');
     $this->totalTime += $this->queries[$key][self::TIME];
     // get EXPLAIN for SELECT queries
     if ($this->doExplains) {
         if ($this->connection === NULL) {
             throw new InvalidStateException('You must set a Doctrine\\DBAL\\Connection to get EXPLAIN.');
         }
         $query = $this->queries[$key][self::SQL];
         if (!Strings::startsWith($query, 'SELECT')) {
             // only SELECTs are supported
             return;
         }
         // prevent logging explains & infinite recursion
         $this->explainRunning = TRUE;
         $params = $this->queries[$key][self::PARAMS];
         $types = $this->queries[$key][self::TYPES];
         $stmt = $this->connection->executeQuery('EXPLAIN ' . $query, $params, $types);
         $this->queries[$key][self::EXPLAIN] = $stmt->fetchAll();
         $this->explainRunning = FALSE;
     }
 }
开发者ID:dtforce,项目名称:nette-doctrine,代码行数:28,代码来源:DoctrineSQLPanel.php

示例2: startup

 public function startup()
 {
     parent::startup();
     \Tracy\Debugger::timer('global');
     // Log visits
     // todo: replace by mongoDB log_visit
     /*
     
     		$httpRequest = $this->getHttpRequest();
     		$requestHeaders = apache_request_headers();
     		$ipAddress = (empty($requestHeaders['X-Forwarded-For']) ? $httpRequest->getRemoteAddress() : $requestHeaders['X-Forwarded-For']);
     		// ip address can be more values divided by comma (it's path to remote server), take only the last (most accurate IP of visitor)
     		$ipAddressParts = explode(',', $ipAddress);
     		$ipAddress = array_pop($ipAddressParts);
     		if ($httpRequest->getUrl()->path != '/healthy-check') {
     
     
     			$this->lastLogItem = $this->logger->logVisit(
     				$httpRequest->getUrl()->path, // URL
     				$ipAddress,  // IP
     				$httpRequest->getHeader('User-Agent'),  // USER_AGENT
     				$httpRequest->getReferer()  // REFERRER
     			);
     		}*/
 }
开发者ID:bamboorat,项目名称:NetteSkeleton,代码行数:25,代码来源:BasePresenter.php

示例3: importTable

 /**
  * @param $tempTableName
  * @param $columns
  * @param CsvFile $csvFile
  * @param array $options
  *  - isManifest
  *  - copyOptions
  * @throws Exception
  * @throws \Exception
  */
 protected function importTable($tempTableName, $columns, CsvFile $csvFile, array $options)
 {
     if ($csvFile->getEnclosure() && $csvFile->getEscapedBy()) {
         throw new Exception('Invalid CSV params. Either enclosure or escapedBy must be specified for Redshift backend but not both.', Exception::INVALID_CSV_PARAMS, null);
     }
     try {
         Debugger::timer('copyToStaging');
         $copyOptions = ['isManifest' => $options['isManifest'], 'copyOptions' => isset($options['copyOptions']) ? $options['copyOptions'] : []];
         if ($options['isManifest']) {
             $manifest = $this->downloadManifest($csvFile->getPathname());
             // empty manifest handling - do nothing
             if (!count($manifest['entries'])) {
                 $this->addTimer('copyToStaging', Debugger::timer('copyToStaging'));
                 return;
             }
             $copyOptions['isGzipped'] = $this->isGzipped(reset($manifest['entries'])['url']);
         } else {
             $copyOptions['isGzipped'] = $this->isGzipped($csvFile->getPathname());
         }
         $this->query($this->generateCopyCommand($tempTableName, $columns, $csvFile, $copyOptions));
         $this->addTimer('copyToStaging', Debugger::timer('copyToStaging'));
     } catch (\Exception $e) {
         $result = $this->connection->query("SELECT * FROM stl_load_errors WHERE query = pg_last_query_id();")->fetchAll();
         if (!count($result)) {
             throw $e;
         }
         $messages = [];
         foreach ($result as $row) {
             $messages[] = "Line {$row['line_number']} - {$row['err_reason']}";
         }
         $message = "Load error: " . implode("\n", $messages);
         throw new Exception($message, Exception::INVALID_SOURCE_DATA, $e);
     }
 }
开发者ID:keboola,项目名称:php-db-import,代码行数:44,代码来源:RedshiftBaseCsv.php

示例4: importDataToStagingTable

 protected function importDataToStagingTable($stagingTableName, $columns, $sourceData)
 {
     if (!isset($sourceData['schemaName'])) {
         throw new Exception('Invalid source data. schemaName must be set', Exception::INVALID_SOURCE_DATA);
     }
     if (!isset($sourceData['tableName'])) {
         throw new Exception('Invalid source data. schemaName must be set', Exception::INVALID_SOURCE_DATA);
     }
     $sql = "INSERT INTO " . $this->nameWithSchemaEscaped($stagingTableName) . " (" . implode(', ', array_map(function ($column) {
         return $this->quoteIdentifier($column);
     }, $columns)) . ") ";
     $sql .= "SELECT " . implode(',', array_map(function ($column) {
         return $this->quoteIdentifier($column);
     }, $columns)) . " FROM " . $this->nameWithSchemaEscaped($sourceData['tableName'], $sourceData['schemaName']);
     try {
         Debugger::timer('copyToStaging');
         $this->connection->query($sql);
         $rows = $this->connection->fetchAll(sprintf('SELECT COUNT(*) as "count" from %s.%s', $this->connection->quoteIdentifier($this->schemaName), $this->connection->quoteIdentifier($stagingTableName)));
         $this->importedRowsCount += (int) $rows[0]['count'];
         $this->addTimer('copyToStaging', Debugger::timer('copyToStaging'));
     } catch (\Exception $e) {
         // everything is user error
         throw new Exception($e->getMessage(), Exception::UNKNOWN_ERROR, $e);
     }
 }
开发者ID:keboola,项目名称:php-db-import,代码行数:25,代码来源:CopyImport.php

示例5: createGuzzleClient

 /**
  * @param $tempDir
  * @param array $guzzleConfig
  * @return \GuzzleHttp\Client
  * @throws \Matyx\Guzzlette\GuzzletteException
  */
 public static function createGuzzleClient($tempDir, $guzzleConfig = [])
 {
     if (isset(static::$client)) {
         return static::$client;
     }
     if (Tracy\Debugger::isEnabled()) {
         $handler = NULL;
         if (isset($guzzleConfig['handler'])) {
             $handler = $guzzleConfig['handler'];
             if (!$handler instanceof GuzzleHttp\HandlerStack) {
                 throw new GuzzletteException("Handler must be instance of " . GuzzleHttp\HandlerStack::class);
             }
         } else {
             $handler = GuzzleHttp\HandlerStack::create();
         }
         $requestStack = new RequestStack();
         Tracy\Debugger::getBar()->addPanel(new TracyPanel($tempDir, $requestStack));
         $handler->push(function (callable $handler) use($requestStack) {
             return function ($request, array $options) use($handler, $requestStack) {
                 Tracy\Debugger::timer();
                 $guzzletteRequest = new Request();
                 $guzzletteRequest->request = $request;
                 return $handler($request, $options)->then(function ($response) use($requestStack, $guzzletteRequest) {
                     $guzzletteRequest->time = Tracy\Debugger::timer();
                     $guzzletteRequest->response = $response;
                     $requestStack->addRequest($guzzletteRequest);
                     return $response;
                 });
             };
         });
         $guzzleConfig['handler'] = $handler;
     }
     static::$client = new GuzzleHttp\Client($guzzleConfig);
     return static::$client;
 }
开发者ID:matyx,项目名称:guzzlette,代码行数:41,代码来源:Guzzlette.php

示例6: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     Debugger::timer();
     $output->writeln('Running tests...');
     $runner = new Runner();
     $path = realpath($input->getArgument('path'));
     if ($path) {
         if (is_dir($path)) {
             $runner->setTestsRoot($path . '/');
             foreach (Finder::findFiles('*.php')->exclude('tester.php')->from($path) as $path => $fileInfo) {
                 $basePath = Helpers::stripExtension($path);
                 $runner->addTest($basePath);
             }
         } else {
             $basePath = Helpers::stripExtension($path);
             $runner->addTest($basePath);
         }
     } else {
         if ($path = realpath($input->getArgument('path') . '.php')) {
             $basePath = Helpers::stripExtension($path);
             $runner->addTest($basePath);
         } else {
             $output->writeln("<error>The given path isn't valid</error>");
             return 1;
         }
     }
     $runner->setOutput($output);
     $runner->runTests();
     $output->writeln('Completed in ' . round(Debugger::timer(), 2) . ' seconds');
     if ($runner->failed()) {
         return 1;
     } else {
         return 0;
     }
 }
开发者ID:blocka,项目名称:php2js,代码行数:35,代码来源:TestCommand.php

示例7: importDataToStagingTable

 protected function importDataToStagingTable($stagingTempTableName, $columns, $sourceData, array $options = [])
 {
     if (!isset($sourceData['schemaName'])) {
         throw new Exception('Invalid source data. schemaName must be set', Exception::INVALID_SOURCE_DATA);
     }
     if (!isset($sourceData['tableName'])) {
         throw new Exception('Invalid source data. schemaName must be set', Exception::INVALID_SOURCE_DATA);
     }
     $sourceColumnTypes = $this->describeTable(strtolower($sourceData['tableName']), strtolower($sourceData['schemaName']));
     $sql = "INSERT INTO " . $this->tableNameEscaped($stagingTempTableName) . " (" . implode(', ', array_map(function ($column) {
         return $this->quoteIdentifier($column);
     }, $columns)) . ") ";
     $sql .= "SELECT " . implode(',', array_map(function ($column) use($sourceColumnTypes) {
         if ($sourceColumnTypes[$column]['DATA_TYPE'] === 'bool') {
             return sprintf('DECODE(%s, true, 1, 0) ', $this->quoteIdentifier($column));
         } else {
             return "COALESCE(CAST({$this->quoteIdentifier($column)} as varchar), '') ";
         }
     }, $columns)) . " FROM " . $this->nameWithSchemaEscaped($sourceData['tableName'], $sourceData['schemaName']);
     try {
         Debugger::timer('copyToStaging');
         $this->query($sql);
         $this->addTimer('copyToStaging', Debugger::timer('copyToStaging'));
     } catch (\Exception $e) {
         if (strpos($e->getMessage(), 'Datatype mismatch') !== false) {
             throw new Exception($e->getMessage(), Exception::DATA_TYPE_MISMATCH, $e);
         }
         // everything is user error
         throw new Exception($e->getMessage(), Exception::UNKNOWN_ERROR, $e);
     }
 }
开发者ID:keboola,项目名称:php-db-import,代码行数:31,代码来源:CopyImportRedshift.php

示例8: stopQuery

 public function stopQuery()
 {
     if (Debugger::$productionMode) {
         return;
     }
     $keys = array_keys($this->queries);
     $key = end($keys);
     $this->queries[$key][2] = Debugger::timer('doctrine');
     $this->totalTime += $this->queries[$key][2];
 }
开发者ID:pipaslot,项目名称:doctrine,代码行数:10,代码来源:QueryPanel.php

示例9: subscribe

 /**
  * subscribe.
  *
  * @method subscribe
  */
 public function subscribe()
 {
     $key = get_class($this);
     $timer = Debugger::timer($key);
     $this->laravel['events']->listen('*', function ($params) use($key) {
         $execTime = Debugger::timer($key);
         $firing = $this->laravel['events']->firing();
         $editorLink = self::editorLink(self::findSource());
         $this->totalTime += $execTime;
         $this->events[] = compact('execTime', 'firing', 'params', 'editorLink');
     });
 }
开发者ID:recca0120,项目名称:laravel-tracy,代码行数:17,代码来源:EventPanel.php

示例10: actionDefault

 public function actionDefault()
 {
     $this->cronner->onTaskBegin[] = function (Cronner $cronner, Task $task) {
         echo '<h3>' . $task->getName() . '</h3>';
         Debugger::timer($task->getName());
     };
     $this->cronner->onTaskFinished[] = function (Cronner $cronner, Task $task) {
         echo '<p>Total time: ' . Debugger::timer($task->getName()) . ' s</p>';
     };
     $this->cronner->run();
     $this->terminate();
 }
开发者ID:arcao,项目名称:menza-nette,代码行数:12,代码来源:CronPresenter.php

示例11: call

 public function call($type, $service, $params = [])
 {
     $url = $this->protocol . $this->host . "/?presenter={$type}&action={$service}";
     if (count($params) > 0) {
         foreach ($params as $name => $value) {
             $url .= "&{$name}={$value}";
         }
     }
     Debugger::timer();
     $data = $this->sendGet($url);
     $time = Debugger::timer();
     return ['data' => $data, 'url' => $url, 'time' => $time];
 }
开发者ID:pogodi,项目名称:OCApi,代码行数:13,代码来源:Tester.php

示例12: subscribe

 public function subscribe(Dispatcher $event)
 {
     $key = get_class($this);
     $timer = Debugger::timer($key);
     $event->listen('*', function ($params) use($key, $event) {
         $execTime = Debugger::timer($key);
         // $dispatcher = static::findDispatcher();
         // $firing = array_get($dispatcher, 'dispatcher.args.0');
         $firing = $event->firing();
         $editorLink = Helper::getEditorLink(Helper::findSource());
         $this->attributes['totalTime'] += $execTime;
         $this->attributes['events'][] = compact('execTime', 'firing', 'params', 'editorLink');
     });
 }
开发者ID:BryceHappy,项目名称:laravel-tracy,代码行数:14,代码来源:EventPanel.php

示例13: execute

 protected function execute($command)
 {
     $time = $timerName = '';
     if (class_exists('\\Tracy\\Debugger')) {
         \Tracy\Debugger::timer($timerName = md5($command));
     }
     $this->logCmd($command, 'Executing');
     $output = shell_exec($command);
     if (class_exists('\\Tracy\\Debugger')) {
         $time = \Tracy\Debugger::timer($timerName);
     }
     $this->logCmd($output, 'Result', $time);
     return $output;
 }
开发者ID:trejjam,项目名称:utils,代码行数:14,代码来源:AShellExecute.php

示例14: subscribe

 public function subscribe()
 {
     $key = get_class($this);
     $timer = Debugger::timer($key);
     $event = $this->app['events'];
     $event->listen('*', function ($params) use($key, $event) {
         $execTime = Debugger::timer($key);
         $firing = $event->firing();
         $editorLink = Helper::getEditorLink(Helper::findSource());
         $this->attributes['count']++;
         $this->attributes['totalTime'] += $execTime;
         $this->attributes['logs'][] = compact('execTime', 'firing', 'params', 'editorLink');
     });
 }
开发者ID:killtw,项目名称:laravel-tracy,代码行数:14,代码来源:EventPanel.php

示例15: stop

 /**
  * Stops the timer and logs event to syslog.
  *
  * @param string $name The timer name.
  * @return float The current timer value.
  */
 public static function stop($name, $data = [])
 {
     $point = Debugger::timer($name);
     $measure = self::add($point, $name);
     if (self::$profile) {
         $tags = [];
         if (isset($data['tags'])) {
             $tags = $data['tags'];
             unset($data['tags']);
         }
         if (function_exists('syslog')) {
             syslog(LOG_INFO, json_encode(['type' => self::$indexName, 'tags' => explode(' ', $name) + $tags, 'host' => gethostname(), 'dur' => round($measure * 1000, 1), 'mem' => memory_get_peak_usage(), 'php' => PHP_VERSION, 'timestamp' => (string) time(), 'data' => array_merge(self::$defaults, $data)]));
         }
     }
     return $measure;
 }
开发者ID:rostenkowski,项目名称:tray,代码行数:22,代码来源:Stopwatch.php


注:本文中的Tracy\Debugger::timer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。