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


PHP Stopwatch::stopSection方法代码示例

本文整理汇总了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--;
 }
开发者ID:bencalie,项目名称:Ciconia,代码行数:33,代码来源:Markdown.php

示例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;
 }
开发者ID:jimlind,项目名称:PHP-CS-Fixer,代码行数:34,代码来源:Fixer.php

示例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;
 }
开发者ID:brighten01,项目名称:opencloud-zendframework,代码行数:36,代码来源:Fixer.php

示例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;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:36,代码来源:Fixer.php

示例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());
 }
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:13,代码来源:StopwatchTest.php

示例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>';
}
开发者ID:nguyenvanduocit,项目名称:Symfony-Stopwatch-Example,代码行数:31,代码来源:section.php


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