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


PHP Stopwatch::openSection方法代码示例

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


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

 /**
  * @dataProvider providerDump
  */
 public function testDump($config, $zipped, $configFormat, $expectedOutput, $expectedFiles, $expectedFilesInZip)
 {
     $output = new BufferedOutput();
     $progress = new ProgressHelper();
     $outputDir = static::$cacheDir . '/dump';
     $stopwatch = new Stopwatch();
     $stopwatch->openSection();
     $this->dumpManager->setStopwatch($stopwatch);
     $this->dumpManager->setOutput($output);
     $this->dumpManager->setProgress($progress);
     $files = $this->dumpManager->dump($config, $outputDir, $zipped, $configFormat);
     $stopwatch->stopSection('generate-test');
     $events = $stopwatch->getSectionEvents('generate-test');
     $keys = ['dumping_config', 'initializing_files', 'generating_rows', 'finalizing_files', 'compressing_files'];
     foreach ($keys as $key) {
         $this->assertArrayHasKey($key, $events);
     }
     $outputContent = $output->fetch();
     $this->assertCount(count($expectedFiles), $files);
     foreach ($expectedFiles as $format => $pattern) {
         $this->assertRegExp('#' . $outputDir . '/' . $pattern . '#', $files[$format]);
     }
     if ($zipped && count($expectedFilesInZip)) {
         $zippedFiles = $this->unzip($files['zip']);
         sort($expectedFilesInZip);
         foreach ($expectedFilesInZip as $format => $pattern) {
             $this->assertRegExp('#' . $pattern . '#', $zippedFiles[$format]);
         }
     }
     $this->assertEquals($expectedOutput, $outputContent);
 }
开发者ID:csanquer,项目名称:fakery-generator,代码行数:34,代码来源:ConsoleDumpManagerTest.php

示例6: get

 /**
  * @param string $id
  * @param int $invalidBehavior
  *
  * @return object
  */
 public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE)
 {
     if (!$this->stopwatch && $this->has('stopwatch')) {
         $this->stopwatch = parent::get('stopwatch');
         $this->stopwatch->openSection();
         $this->hasStopwatch = TRUE;
     }
     if ('stopwatch' === $id) {
         return $this->stopwatch;
     }
     Timer::start($id);
     if ($this->hasStopwatch) {
         $e = $this->stopwatch->start($id, 'service');
     }
     $service = parent::get($id, $invalidBehavior);
     $this->tracedData[$id] = Timer::stop($id);
     if ($this->hasStopwatch && $e->isStarted()) {
         $e->stop();
     }
     return $service;
 }
开发者ID:sgtsaughter,项目名称:d8portfolio,代码行数:27,代码来源:TraceableContainer.php

示例7: testReopenANewSectionShouldThrowAnException

 /**
  * @expectedException \LogicException
  */
 public function testReopenANewSectionShouldThrowAnException()
 {
     $stopwatch = new Stopwatch();
     $stopwatch->openSection('section');
 }
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:8,代码来源:StopwatchTest.php

示例8: 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

示例9: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $stopwatch = new Stopwatch();
     $stopwatch->openSection();
     $app = $this->getApplication()->getSilex();
     $configFile = $input->getArgument('config');
     if (!file_exists($configFile)) {
         throw new \InvalidArgumentException('The config file ' . $configFile . ' does not exists.');
     }
     $configFileExtension = pathinfo($configFile, PATHINFO_EXTENSION);
     if (!in_array($configFileExtension, ['json', 'xml'])) {
         throw new \InvalidArgumentException('The config file ' . $configFile . ' must be a JSON or XML file.');
     }
     $outputConfigFormat = $input->getOption('config-format');
     if (!in_array($outputConfigFormat, ['json', 'xml', 'all', 'auto'])) {
         throw new \InvalidArgumentException('The output config file format ' . $outputConfigFormat . ' is not allowed.');
     }
     if ($outputConfigFormat == 'auto') {
         $outputConfigFormat = $configFileExtension;
     }
     $output->writeln('Loading <info>' . $configFile . '</info> ...');
     $noZip = $input->getOption('no-zip');
     $fakeNumber = $input->getOption('number');
     $stopwatch->start('loading_config', 'generate_dumps');
     $serializer = $app['fakery.config_serializer'];
     $config = $serializer->load($configFile);
     $config->setFakerConfig($app['fakery.faker.config']);
     //Configuration file Validation
     $errors = $app['validator']->validate($config);
     if (count($errors) > 0) {
         $flatErrors = [];
         foreach ($errors as $error) {
             $flatErrors[] = $error->getPropertyPath() . ' : ' . $error->getMessage();
         }
         throw new \InvalidArgumentException('The config file ' . $configFile . ' is not a valid Fakery generator config file.' . "\n\n" . implode("\n", $flatErrors));
     }
     $stopwatch->stop('loading_config');
     $outputDir = $input->getArgument('output-dir');
     if (empty($outputDir) || file_exists($outputDir) && !is_dir($outputDir)) {
         $outputDir = 'dump/' . time() . '_' . uniqid() . '_' . $config->getClassName(true);
     }
     if (is_numeric($fakeNumber)) {
         $config->setFakeNumber($fakeNumber);
     }
     $dumpManager = $app['fakery.console_dumper_manager'];
     $dumpManager->setStopwatch($stopwatch);
     $dumpManager->setOutput($output);
     $dumpManager->setProgress($this->getHelperSet()->get('progress'));
     $files = $dumpManager->dump($config, $outputDir, !$noZip, $outputConfigFormat);
     $stopwatch->stopSection('generate');
     $events = $stopwatch->getSectionEvents('generate');
     foreach ($files as $file) {
         $output->writeln('<info>' . $file . '</info> generated');
     }
     $output->writeln("\n" . 'Performance Summary :' . "\n");
     $totalEvent = isset($events['__section__']) ? $events['__section__'] : null;
     unset($events['__section__']);
     foreach ($events as $name => $event) {
         $this->formatStopwatchEvent($name, $event, $output, false);
     }
     $this->formatStopwatchEvent('total', $totalEvent, $output, true);
 }
开发者ID:csanquer,项目名称:fakery-generator,代码行数:62,代码来源:GenerateCommand.php


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