本文整理汇总了PHP中Symfony\Component\Stopwatch\Stopwatch::start方法的典型用法代码示例。如果您正苦于以下问题:PHP Stopwatch::start方法的具体用法?PHP Stopwatch::start怎么用?PHP Stopwatch::start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Stopwatch\Stopwatch
的用法示例。
在下文中一共展示了Stopwatch::start方法的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;
}
示例2: startProfiling
/**
* @param CleverAge\Orchestrator\Events\ServiceEvent $event
* @return Symfony\Component\Stopwatch\StopwatchEvent
*/
protected function startProfiling(ServiceEvent $event)
{
if ($this->stopwatch instanceof Stopwatch) {
$this->profiles[$event->getService()->getName()][$this->counter] = array('method' => $event->getRequestMethod(), 'parameters' => print_r($event->getRequestParameters(), true), 'results' => null, 'duration' => null, 'result_count' => 0);
return $this->stopwatch->start($event->getService()->getName() . '_' . $this->counter);
}
}
示例3: 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--;
}
示例4: onBuildStarted
/**
* @param App\CoreBundle\Event\BuildStartedEvent
*/
public function onBuildStarted(BuildStartedEvent $event)
{
$build = $event->getBuild();
$this->logger->info('starting stopwatch for build #' . $build->getId());
$this->stopwatch->start($build->getChannel());
$build->setStartTime(new DateTime());
}
示例5: start
/**
* @param Event $e
*/
private function start(Event $e)
{
$request = $e['request'];
$this->requests[$this->hash($request)] = count($this->requests) + 1;
$name = $this->getEventName($request);
$this->stopwatch->start($name, 'guzzle');
}
示例6: enter
/**
* {@inheritdoc}
*/
public function enter(\Twig_Profiler_Profile $profile)
{
if ($this->stopwatch && $profile->isTemplate()) {
$this->events[$profile] = $this->stopwatch->start($profile->getName(), 'template');
}
parent::enter($profile);
}
示例7: 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;
}
示例8: onBeforeInvoke
/**
* @param InvokeEvent $event
*/
public function onBeforeInvoke(InvokeEvent $event)
{
if (!$this->stopwatch) {
return;
}
$this->stopwatch->start('invoke ' . $event->getDirectRequest()->getRequestKey());
}
示例9: 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);
}
示例10: 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;
}
示例11: 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);
}
示例12: 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());
}
示例13: 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;
}
示例14: 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;
}
示例15: __call
/**
* @internal
*
* @param string $name
* @param array $arguments
*
* @return mixed
*/
public function __call($name, array $arguments)
{
$this->stopwatch->start($this->name, $name);
$this->logger->debug('> ' . $this->name . '::' . $name, $arguments);
$r = call_user_func_array([$this->originalClient, $name], $arguments);
$this->logger->debug('< ' . $this->name . '::' . $name, [$r]);
$this->stopwatch->stop($this->name);
return $r;
}