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


PHP Stopwatch::isStarted方法代码示例

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


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

 /**
  * Ends the watch, extract logs and write them to the storage service chosen.
  * @param $identifier
  * @param OutputInterface|null $output If you want to write on output the logs
  * @param array $extra
  *
  * @return array
  */
 public function end($identifier, OutputInterface $output = null, $extra = array())
 {
     $logs = array();
     if ($this->stopWatch->isStarted($identifier)) {
         $stopWatchEvent = $this->stopWatch->stop($identifier);
         $logs = $this->extractLog($stopWatchEvent, $output, $extra);
         $this->writer->write($logs, $identifier);
     }
     return $logs;
 }
开发者ID:sowbiba,项目名称:command-watcher-bundle,代码行数:18,代码来源:Watcher.php

示例3: tick

 /**
  * Mark action for the event on Stopwatch.
  *
  * @param mixed $input pass through if added to filter
  *
  * @return mixed
  */
 static function tick($input = null)
 {
     global $wp_filter;
     $filter = current_filter();
     $priority = key($wp_filter[$filter]);
     $event = wp_parse_args(self::$events[$filter][$priority], array('action' => 'start', 'category' => null));
     if ('stop' === $event['action'] && !self::$stopwatch->isStarted($event['event'])) {
         return $input;
     }
     self::$stopwatch->{$event['action']}($event['event'], $event['category']);
     return $input;
 }
开发者ID:anboto,项目名称:laps,代码行数:19,代码来源:class-laps.php

示例4: stopwatch

 public static function stopwatch(Stopwatch $stopwatch)
 {
     return function (callable $handler) use($stopwatch) {
         return function (RequestInterface $request, array $options) use($handler, $stopwatch) {
             $uri = (string) $request->getUri();
             if (!$stopwatch->isStarted($uri)) {
                 $stopwatch->start($uri);
             }
             return $handler($request, $options)->then(function (ResponseInterface $response) use($stopwatch, $uri) {
                 $stopwatch->stop($uri);
                 return $response;
             });
         };
     };
 }
开发者ID:danut007ro,项目名称:CsaGuzzleBundle,代码行数:15,代码来源:Middleware.php

示例5: finishProcess

 /**
  * Finish current licenser process log and display results in the output.
  */
 public function finishProcess()
 {
     $total = $this->countTotal();
     $additions = $this->countAdditions();
     $updates = $this->countUpdates();
     $untouched = $this->countUntouched();
     $formatter = new FormatterHelper();
     //summary
     $this->output->writeln('', OutputInterface::VERBOSITY_VERBOSE);
     $this->output->writeln(sprintf('<fg=green>[+] Additions: %s</>', $additions), OutputInterface::VERBOSITY_VERBOSE);
     $this->output->writeln(sprintf('<fg=cyan>[u] Updates: %s</>', $updates), OutputInterface::VERBOSITY_VERBOSE);
     $this->output->writeln(sprintf('<fg=yellow>[=] Untouched: %s</>', $untouched), OutputInterface::VERBOSITY_VERBOSE);
     $this->output->writeln('');
     if ($this->watch->isStarted('licenser')) {
         $event = $this->watch->stop('licenser');
         $processMessage = sprintf('%s file(s) has been processed in %s ms, memory usage %.2F MiB', $total, $event->getDuration(), $event->getMemory() / 1024 / 1024);
         if ($this->mode & Licenser::MODE_NORMAL || $this->mode & Licenser::MODE_DRY_RUN) {
             $style = new OutputFormatterStyle('white', $this->mode === Licenser::MODE_DRY_RUN ? 'cyan' : 'green', ['bold']);
             $this->output->getFormatter()->setStyle('success', $style);
             $formattedBlock = $formatter->formatBlock($processMessage, 'success', true);
             $this->output->writeln($formattedBlock);
         } elseif ($this->mode & Licenser::MODE_CHECK_ONLY) {
             $needUpdate = $additions + $updates > 0;
             if ($needUpdate) {
                 $successMsg = sprintf('[WARN] %s file(s) should be updated.', $additions + $updates);
             } else {
                 $successMsg = '[OK] All files contains a valid license header.';
             }
             $style = new OutputFormatterStyle('white', $needUpdate ? 'red' : 'green', ['bold']);
             $this->output->getFormatter()->setStyle('success', $style);
             $formattedBlock = $formatter->formatBlock([$successMsg, $processMessage], 'success', true);
             $this->output->writeln($formattedBlock);
         }
         if ($this->mode === Licenser::MODE_DRY_RUN) {
             $this->output->writeln('');
             $this->output->writeln('<fg=yellow>NOTE: The command run in dry-run mode, it not made any changes.</>');
         }
     }
 }
开发者ID:rafrsr,项目名称:licenser,代码行数:42,代码来源:ProcessLogger.php

示例6: testIsNotStarted

 public function testIsNotStarted()
 {
     $stopwatch = new Stopwatch();
     $this->assertFalse($stopwatch->isStarted('foo'));
 }
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:5,代码来源:StopwatchTest.php

示例7: admin_bar_menu

 /**
  * Render interface and add to the toolbar.
  *
  * @param \WP_Admin_Bar $wp_admin_bar
  */
 public static function admin_bar_menu($wp_admin_bar)
 {
     if (!apply_filters('laps_can_see', current_user_can('manage_options'))) {
         return;
     }
     global $timestart, $wpdb;
     $mustache = new \Mustache_Engine(array('loader' => new \Mustache_Loader_FilesystemLoader(dirname(__DIR__) . '/views'), 'cache' => new Mustache_Cache_FrozenCache(dirname(__DIR__) . '/views/cache')));
     if (self::$stopwatch->isStarted('Toolbar')) {
         self::$stopwatch->stop('Toolbar');
     }
     $events = self::$stopwatch->getSectionEvents('__root__');
     $start = $timestart * 1000;
     $end = microtime(true) * 1000;
     $total = $end - $start;
     $event_data = array();
     $http_data = array();
     foreach ($events as $name => $event) {
         $offset = round(($event->getOrigin() - $start) / $total * 100, 2);
         $duration = $event->getDuration();
         $width = round($duration / $total * 100, 2);
         $category = $event->getCategory();
         if ('http' === $category) {
             $http_data[] = compact('name', 'offset', 'duration', 'width', 'category');
             continue;
         }
         $memory = $event->getMemory() / 1024 / 1024;
         $event_data[] = compact('name', 'offset', 'duration', 'width', 'category', 'memory');
     }
     $query_data = array();
     $last_query_end = 0;
     $last_offset = 0;
     $last_duration = 0;
     if (defined('SAVEQUERIES') && SAVEQUERIES) {
         foreach ($wpdb->queries as $key => $query) {
             $query_start = isset(self::$query_starts[$key]) ? self::$query_starts[$key] : $last_query_end;
             list($sql, $duration, $trace) = $query;
             $sql = trim($sql);
             $category = 'query-read';
             if (0 === stripos($sql, 'INSERT') || 0 === stripos($sql, 'UPDATE')) {
                 $category = 'query-write';
             }
             $duration *= 1000;
             $last_query_end = $query_start + $duration;
             $offset = round(($query_start - $start) / $total * 100, 2);
             // if query is indistinguishably close to previous then stack it
             if ($offset === $last_offset) {
                 $key = count($query_data) - 1;
                 $query_data[$key]['sql'] .= '<br />' . $sql;
                 $last_duration += $duration;
                 $width = round($last_duration / $total * 100, 2);
                 $query_data[$key]['width'] = $width;
                 continue;
             }
             $width = round($duration / $total * 100, 2);
             $last_offset = $offset;
             $last_duration = $duration;
             $query_data[] = compact('sql', 'duration', 'offset', 'width', 'category');
         }
     }
     $html = $mustache->render('laps', array('events' => $event_data, 'queries' => $query_data, 'savequeries' => defined('SAVEQUERIES') && SAVEQUERIES, 'http' => $http_data, 'savehttp' => !empty($http_data)));
     $wp_admin_bar->add_node(array('id' => 'laps', 'title' => sprintf('Lap: %ss', round($total / 1000, 3))));
     $wp_admin_bar->add_node(array('id' => 'laps_output', 'parent' => 'laps', 'meta' => array('html' => $html)));
 }
开发者ID:rarst,项目名称:laps,代码行数:68,代码来源:class-laps.php


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