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


PHP Stopwatch::stop方法代码示例

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


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

示例1: rasterizeUrl

 /**
  * @param        $url
  * @param array  $arguments
  * @param string $uniqueId
  *
  * @throws \Exception
  *
  * @return string
  */
 public function rasterizeUrl($url, $arguments = array(), $uniqueId = "")
 {
     if ($uniqueId === "") {
         $uniqueId = uniqid("rasterize-");
     }
     if ($this->stopwatch instanceof Stopwatch) {
         if ($this->stopwatch->isStarted($uniqueId)) {
             $this->stopwatch->lap($uniqueId);
         } else {
             $this->stopwatch->start($uniqueId);
         }
     }
     $process = $this->configHelper->buildProcess($url, $uniqueId, $arguments);
     $exitCode = $process->run();
     if ($exitCode != 0) {
         throw new \Exception(sprintf("Rasterize script failed.\nCommandLine: %s\nExitCode: %d\nErrorOutput: %s", $process->getCommandLine(), $process->getExitCode(), $process->getErrorOutput()));
     }
     if ($this->stopwatch instanceof Stopwatch) {
         $this->stopwatch->stop($uniqueId);
     }
     $output = $this->configHelper->getOutputFilePath($uniqueId);
     $content = file_get_contents($output);
     unlink($output);
     return $content;
 }
开发者ID:baiolo,项目名称:RasterizeBundle,代码行数:34,代码来源:Rasterizer.php

示例2:

 function it_stops(Stopwatch $stopwatch, StopwatchEvent $event)
 {
     $stopwatch->getEvent('dom_manipulator_rules')->shouldBeCalled()->willReturn($event);
     $stopwatch->stop('dom_manipulator')->shouldBeCalled()->willReturn($event);
     $stopwatch->stop('dom_manipulator_manipulation')->shouldBeCalled()->willReturn($event);
     $this->stop();
 }
开发者ID:netzmacht,项目名称:contao-dom-manipulator,代码行数:7,代码来源:StopwatchSubscriberSpec.php

示例3: log

 /**
  * Logs with an arbitrary level.
  *
  * @param  mixed  $level
  * @param  string $message
  * @param  array  $context
  * @return null
  */
 public function log($level, $message, array $context = array())
 {
     if (null === $this->logger) {
         return;
     }
     $add = true;
     $stackTrace = $this->getStackTrace();
     if (null !== $this->stopwatch) {
         $trace = debug_backtrace();
         $method = $trace[3]['function'];
         $watch = 'Propel Query ' . (count($this->queries) + 1);
         if ('prepare' === $method) {
             $this->isPrepared = true;
             $this->stopwatch->start($watch, 'propel');
             $add = false;
         } elseif ($this->isPrepared) {
             $this->isPrepared = false;
             $event = $this->stopwatch->stop($watch);
         }
     }
     // $trace[2] has no 'object' key if an exception is thrown while executing a query
     if ($add && isset($event) && isset($trace[2]['object'])) {
         $connection = $trace[2]['object'];
         $this->queries[] = array('sql' => $message, 'connection' => $connection->getName(), 'time' => $event->getDuration() / 1000, 'memory' => $event->getMemory(), 'stackTrace' => $stackTrace);
     }
     $this->logger->log($level, $message, $context);
 }
开发者ID:naldz,项目名称:cyberden,代码行数:35,代码来源:PropelLogger.php

示例4: compile

 /**
  * @return string
  */
 public function compile()
 {
     $this->stopwatch->start('webpack.total');
     $this->stopwatch->start('webpack.prepare');
     // Recompile twig templates where its needed.
     $this->addSplitPoints();
     $this->addResolveConfig();
     // Write the webpack configuration file.
     file_put_contents($this->cache_dir . DIRECTORY_SEPARATOR . 'webpack.config.js', $this->generator->getConfiguration());
     $this->profiler->set('compiler.performance.prepare', $this->stopwatch->stop('webpack.prepare')->getDuration());
     $this->stopwatch->start('webpack.compiler');
     $this->process->run();
     $output = $this->process->getOutput() . $this->process->getErrorOutput();
     $this->profiler->set('compiler.executed', true);
     $this->profiler->set('compiler.successful', strpos($output, 'Error:') === false);
     $this->profiler->set('compiler.last_output', $output);
     if ($this->profiler->get('compiler.successful')) {
         $this->tracker->rebuild();
     }
     // Finally, write some logging for later use.
     file_put_contents($this->cache_dir . DIRECTORY_SEPARATOR . 'webpack.compiler.log', $output);
     $this->profiler->set('compiler.performance.compiler', $this->stopwatch->stop('webpack.compiler')->getDuration());
     $this->profiler->set('compiler.performance.total', $this->stopwatch->stop('webpack.total')->getDuration());
     return $output;
 }
开发者ID:studionone,项目名称:webpack-bundle,代码行数:28,代码来源:Compiler.php

示例5: getLogData

 /**
  * @param RequestInterface  $request
  * @param ResponseInterface $response
  *
  * @return array
  */
 protected function getLogData(RequestInterface $request, ResponseInterface $response = null)
 {
     $time = $this->stopwatch->stop(self::STOPWATCH_EVENT)->getDuration();
     $uagent = $request->getHeader('User-Agent', '-');
     $uagent = $uagent[0];
     $xcache = $response && $response->hasHeaderWithValue('x-cache', 'HIT') ? 'HIT' : 'MISS';
     $postDumpLimit = 200;
     $postData = json_encode($request->getPostParams());
     if (strlen($postData) > $postDumpLimit) {
         $postData = substr($postData, 0, $postDumpLimit) . '...';
     }
     $data = array();
     $data[] = $xcache;
     $data[] = bcdiv($time, 1000, 4);
     // milliseconds
     $data[] = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1';
     // @todo ip is always set to 127.0.0.1 due to broken request object
     $data[] = $request->getMethod();
     $data[] = $request->getUri();
     $data[] = $response ? $response->getStatusCode() : '-';
     // bytes
     $data[] = $response ? $response->getLength() : '-';
     // bytes
     $data[] = sprintf('"%s"', $uagent);
     $data[] = $postData;
     return $data;
 }
开发者ID:phpextra,项目名称:proxy,代码行数:33,代码来源:AccessLoggerListener.php

示例6: invoke

 /** {@inheritdoc} */
 public function invoke($calls)
 {
     $this->stopwatch->start($this->clientName, 'rpc_call');
     $collection = new TraceableResponseCollection($this->client->invoke($calls), $this->stopwatch, $this->clientName);
     $this->stopwatch->stop($this->clientName);
     return $collection;
 }
开发者ID:bankiru,项目名称:doctrine-api-bundle,代码行数:8,代码来源:TraceableClient.php

示例7: emit

 /**
  * @param $event
  * @param $parameters
  *
  * @return mixed|void
  */
 public function emit($event, $parameters)
 {
     self::$depth++;
     $this->stopwatch->openSection();
     if (isset($this->callbacks[$event])) {
         if (!$this->callbacks[$event][0]) {
             usort($this->callbacks[$event][1], function ($A, $B) {
                 if ($A[0] == $B[0]) {
                     return 0;
                 }
                 return $A[0] > $B[0] ? 1 : -1;
             });
             $this->callbacks[$event][0] = true;
         }
         foreach ($this->callbacks[$event][1] as $item) {
             $name = $this->getCallableName($item[1]);
             $this->stopwatch->start($name);
             $diagnoseEvent = Event::create()->setEvent($event)->setCallback($name)->setDepth(self::$depth);
             $this->events[] = $diagnoseEvent;
             call_user_func_array($item[1], $this->buildParameters($parameters));
             $stopwatchEvent = $this->stopwatch->stop($name);
             $diagnoseEvent->setDuration($stopwatchEvent->getDuration())->setMemory($stopwatchEvent->getMemory());
         }
     }
     $this->stopwatch->stopSection($event);
     self::$depth--;
 }
开发者ID:bencalie,项目名称:Ciconia,代码行数:33,代码来源:Markdown.php

示例8: getResponse

 /** {@inheritdoc} */
 public function getResponse(RpcRequestInterface $request)
 {
     $this->stopwatch->start($this->client, 'rpc_response');
     $response = $this->collection->getResponse($request);
     $this->stopwatch->stop($this->client);
     return $response;
 }
开发者ID:bankiru,项目名称:doctrine-api-bundle,代码行数:8,代码来源:TraceableResponseCollection.php

示例9: fetchWithNamespace

 /**
  * @inheritDoc
  */
 public function fetchWithNamespace($id, $namespaceId = null)
 {
     self::$stopwatch->start('doctrine_cache_extension_bundle');
     $data = $this->cacheProviderDecorator->fetchWithNamespace($id, $namespaceId);
     self::$stopwatch->stop('doctrine_cache_extension_bundle');
     self::$collectedData[self::$callId++] = new FetchWithNamespaceCacheCollectedData($id, $namespaceId, $data, self::$stopwatch);
     return $data;
 }
开发者ID:emilyreese,项目名称:DoctrineCacheExtensionBundle,代码行数:11,代码来源:DebugCacheProviderDecorator.php

示例10: stopQuery

 /**
  * @return void
  */
 public function stopQuery()
 {
     if ($this->stopwatch) {
         $this->stopwatch->stop('sphinx');
     }
     $this->queries[$this->queryCurrent]['time'] = microtime(true) - $this->queryStart;
     $this->queryCurrent++;
 }
开发者ID:vchebotarev,项目名称:sphinx-bundle,代码行数:11,代码来源:Logger.php

示例11: onConsoleTerminate

 /**
  * @param ConsoleTerminateEvent $event
  */
 public function onConsoleTerminate(ConsoleTerminateEvent $event)
 {
     if ('check' == $event->getCommand()->getName()) {
         $stopEvent = $this->stopwatch->stop('check_command');
         $output = $event->getOutput();
         $output->writeln(sprintf('Checked source files in %s seconds, %s MB memory used', $stopEvent->getDuration() / 1000, $stopEvent->getMemory() / 1024 / 1024));
     }
 }
开发者ID:rnuernberg,项目名称:deprecation-detector,代码行数:11,代码来源:CommandListener.php

示例12: collectFilter

 /**
  * @param string $function
  * @param array  $arguments
  *
  * @return mixed
  */
 private function collectFilter($function, $arguments)
 {
     $this->stopwatch->start('acl.filters');
     $result = call_user_func_array([$this->aclFilter, $function], $arguments);
     $periods = $this->stopwatch->stop('acl.filters')->getPeriods();
     $this->filters[] = ['method' => $function, 'query' => $result->getSQL(), 'time' => end($periods)->getDuration()];
     return $result;
 }
开发者ID:dragosprotung,项目名称:AclBundle,代码行数:14,代码来源:AclFilterCollector.php

示例13: onKernelTerminate

 /**
  * @param PostResponseEvent $event
  */
 public function onKernelTerminate(PostResponseEvent $event)
 {
     $stopwatchEvent = $this->stopwatch->stop('request');
     $duration = $stopwatchEvent->getDuration();
     $attributes = $this->flattenAttributes($event->getRequest()->attributes->all());
     $data = ['service' => 'request.duration', 'metrics' => $duration];
     $this->logger->log($data, $attributes);
 }
开发者ID:trademachines,项目名称:riemann-logging-bundle,代码行数:11,代码来源:RequestListener.php

示例14: trace

 /**
  * {@inheritdoc}
  */
 public function trace(array $spans)
 {
     $key = count($spans) == 1 ? $spans[0]->getName() : count($spans);
     $key = 'trace (' . $key . ')';
     $this->stopwatch->start($key);
     $this->decoratedTracer->trace($spans);
     $this->stopwatch->stop($key);
 }
开发者ID:sroze,项目名称:tolerance,代码行数:11,代码来源:WatchedTracer.php

示例15: push

 /**
  * @param string|array $data
  * @param string       $routeName
  * @param array[]      $routeParameters
  */
 public function push($data, $routeName, array $routeParameters = array(), array $context = [])
 {
     $eventName = 'push.' . $this->getName();
     $this->stopwatch->start($eventName, 'websocket');
     $this->pusher->push($data, $routeName, $routeParameters, $context);
     $this->stopwatch->stop($eventName);
     $this->dataCollector->collectData($this->stopwatch->getEvent($eventName), $this->getName());
 }
开发者ID:rsrodrig,项目名称:MeetMeSoftware,代码行数:13,代码来源:PusherDecorator.php


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