本文整理匯總了PHP中Symfony\Component\Stopwatch\Stopwatch::stopSection方法的典型用法代碼示例。如果您正苦於以下問題:PHP Stopwatch::stopSection方法的具體用法?PHP Stopwatch::stopSection怎麽用?PHP Stopwatch::stopSection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\Stopwatch\Stopwatch
的用法示例。
在下文中一共展示了Stopwatch::stopSection方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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--;
}
示例2: fix
/**
* Fixes all files for the given finder.
*
* @param ConfigInterface $config A ConfigInterface instance
* @param bool $dryRun Whether to simulate the changes or not
* @param bool $diff Whether to provide diff
*
* @return array
*/
public function fix(ConfigInterface $config, $dryRun = false, $diff = false)
{
$changed = array();
$fixers = $config->getFixers();
$this->stopwatch->openSection();
$fileCacheManager = new FileCacheManager($config->usingCache(), $config->getCacheFile(), $config->getRules());
$processed = array();
foreach ($config->getFinder() as $file) {
$name = $this->getFileRelativePathname($file);
if (in_array($name, $processed, true)) {
continue;
}
$processed[] = $name;
if ($file->isDir() || $file->isLink()) {
continue;
}
$this->stopwatch->start($this->getFileRelativePathname($file));
if ($fixInfo = $this->fixFile($file, $fixers, $dryRun, $diff, $fileCacheManager)) {
$changed[$name] = $fixInfo;
}
$this->stopwatch->stop($this->getFileRelativePathname($file));
}
$this->stopwatch->stopSection('fixFile');
return $changed;
}
示例3: fix
/**
* Fixes all files for the given finder.
*
* @param ConfigInterface $config A ConfigInterface instance
* @param bool $dryRun Whether to simulate the changes or not
* @param bool $diff Whether to provide diff
*
* @return array
*/
public function fix(ConfigInterface $config, $dryRun = false, $diff = false)
{
$fixers = $this->prepareFixers($config);
$changed = array();
if ($this->stopwatch) {
$this->stopwatch->openSection();
}
$fileCacheManager = new FileCacheManager($config->usingCache(), $config->getDir());
foreach ($config->getFinder() as $file) {
if ($file->isDir()) {
continue;
}
if ($this->stopwatch) {
$this->stopwatch->start($this->getFileRelativePathname($file));
}
if ($fixInfo = $this->fixFile($file, $fixers, $dryRun, $diff, $fileCacheManager)) {
$changed[$this->getFileRelativePathname($file)] = $fixInfo;
}
if ($this->stopwatch) {
$this->stopwatch->stop($this->getFileRelativePathname($file));
}
}
if ($this->stopwatch) {
$this->stopwatch->stopSection('fixFile');
}
return $changed;
}
示例4: fix
/**
* Fixes all files for the given finder.
*
* @param ConfigInterface $config A ConfigInterface instance
* @param bool $dryRun Whether to simulate the changes or not
* @param bool $diff Whether to provide diff
*
* @return array
*/
public function fix(ConfigInterface $config, $dryRun = false, $diff = false)
{
$fixers = $this->prepareFixers($config);
$fixers = $this->sortFixers($fixers);
$changed = array();
if ($this->stopwatch) {
$this->stopwatch->openSection();
}
$fileCacheManager = new FileCacheManager($config->usingCache(), $config->getDir(), $fixers);
$finder = $config->getFinder();
$finderIterator = $finder instanceof \IteratorAggregate ? $finder->getIterator() : $finder;
foreach (new UniqueFileIterator($finderIterator) as $file) {
if ($this->stopwatch) {
$this->stopwatch->start($this->getFileRelativePathname($file));
}
if ($fixInfo = $this->fixFile($file, $fixers, $dryRun, $diff, $fileCacheManager)) {
$changed[$this->getFileRelativePathname($file)] = $fixInfo;
}
if ($this->stopwatch) {
$this->stopwatch->stop($this->getFileRelativePathname($file));
}
}
if ($this->stopwatch) {
$this->stopwatch->stopSection('fixFile');
}
return $changed;
}
示例5: testReopenASection
public function testReopenASection()
{
$stopwatch = new Stopwatch();
$stopwatch->openSection();
$stopwatch->start('foo', 'cat');
$stopwatch->stopSection('section');
$stopwatch->openSection('section');
$stopwatch->start('bar', 'cat');
$stopwatch->stopSection('section');
$events = $stopwatch->getSectionEvents('section');
$this->assertCount(3, $events);
$this->assertCount(2, $events['__section__']->getPeriods());
}
示例6: Stopwatch
<?php
require_once 'vendor/autoload.php';
require_once 'functions.php';
use Symfony\Component\Stopwatch\Stopwatch;
$stopwatch = new Stopwatch();
$stopwatch->openSection();
$stopwatch->start('do_phase_1');
doSomeFunction();
$stopwatch->stopSection('step1');
$stopwatch->openSection();
$stopwatch->start('do_phase_1');
$totalLap = 10;
for ($count = 0; $count < $totalLap; $count++) {
doSomeFunction();
$stopwatch->lap('do_phase_1');
}
$stopwatch->stopSection('step2');
echo '<p>Step 1 :</p>';
$events_1 = $stopwatch->getSectionEvents('step1');
echo '<ul>';
foreach ($events_1 as $id => $event) {
echo '<li> phase ' . $id . ':' . $event->getDuration() . '</li>';
}
echo '</ul>';
echo '<p>Step 2 :</p>';
$events_2 = $stopwatch->getSectionEvents('step2');
echo '<ul>';
foreach ($events_2 as $id => $event) {
echo '<li> phase ' . $id . ':' . $event->getDuration() . '</li>';
}