本文整理汇总了PHP中PHP_Timer::resourceUsage方法的典型用法代码示例。如果您正苦于以下问题:PHP PHP_Timer::resourceUsage方法的具体用法?PHP PHP_Timer::resourceUsage怎么用?PHP PHP_Timer::resourceUsage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHP_Timer
的用法示例。
在下文中一共展示了PHP_Timer::resourceUsage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: printResult
/**
* Prints a result set from PHPDCD_Detector::detectDeadCode().
*
* @param array $result
* @param string $commonPath
*/
public function printResult(array $result, $commonPath)
{
foreach ($result as $name => $source) {
printf("\n - %s()\n declared in %s:%d\n", $name, str_replace($commonPath, '', $source['file']), $source['line']);
}
print "\n" . PHP_Timer::resourceUsage() . "\n";
}
示例2: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
if (\App::environment() === 'production') {
$this->error('This feature is not available on this server');
}
$command = base_path('vendor' . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'apigen') . ' generate -s app -d phpdoc';
$this->comment($command);
$process = new Process($command);
$process->run(function ($type, $buffer) {
$buffer = trim($buffer);
if (empty($buffer)) {
return;
}
if ('err' === $type) {
$this->error($buffer);
} else {
$this->comment($buffer);
}
});
if (!$process->isSuccessful()) {
$this->error($process->getErrorOutput());
return;
}
$this->comment('Documentation generated in folder ' . base_path('phpdoc'));
$this->comment(\PHP_Timer::resourceUsage());
}
示例3: printFooter
protected function printFooter(PHPUnit_Framework_TestResult $result)
{
$this->write('<div class="stats">');
parent::printFooter($result);
$this->write('</div>');
$this->write('<div class="resourceUsage">');
$this->write(PHP_Timer::resourceUsage());
$this->write('</div>');
}
示例4: twigRender
public function twigRender($template, $output = [])
{
$output['resources'] = \PHP_Timer::resourceUsage();
$fullPath = $this->templatePath . $template;
$templateFile = strrchr($fullPath, DS);
$loader = new \Twig_Loader_Filesystem(str_replace($templateFile, '', $fullPath));
$twig = new \Twig_Environment($loader);
return $twig->render($templateFile, $output);
}
示例5: renderTwig
public function renderTwig($layout, $params = [])
{
$time = \PHP_Timer::resourceUsage();
$params['time'] = $time;
$loader = new \Twig_Loader_Filesystem([str_replace('\\', '/', __DIR__ . '/layouts'), str_replace('\\', '/', __DIR__ . '/templates')]);
$twig = new \Twig_Environment($loader, ['cache' => false]);
$content = $twig->render($layout, $params);
return $content;
}
示例6: actionOne
/**
* Метод вывода одной новости по её id
*
*/
protected function actionOne()
{
$id = (int) $_GET['id'] ?: false;
if (empty($id)) {
$this->redirect('/');
}
if (!empty($article = NewsModel::findById($id))) {
$this->view->render('/news/one.html', ['article' => $article, 'resource' => \PHP_Timer::resourceUsage()]);
} else {
$this->view->erroradmin = false;
throw new Exception404('Страница с такой новостью не найдена');
}
}
示例7: __construct
/**
* Class constructor for full/combined report
*
* @param string $source Data source
* @param array $options Options for parser
* @param array $warnings List of warning messages already produced
* @param array $reportChilds List of reports to print
*/
public function __construct($source, $options, $warnings, $reportChilds)
{
$pci = new PHP_CompatInfo($options);
if ($pci->parse($source) === false) {
return;
}
$reportResults = $pci->toArray();
$masterResults = $reportResults[0];
if ($options['verbose'] < 3) {
$reportResults = $reportResults[0];
} else {
unset($reportResults[0]);
}
$base = realpath($source);
if (is_file($base)) {
$base = dirname($base);
}
$allWarnings = array_unique(array_merge($warnings, $pci->getWarnings()));
$options = $pci->getOptions();
if (empty($reportChilds)) {
$reportChilds = array('summary', 'extension', 'interface', 'trait', 'class', 'function', 'constant', 'global', 'token', 'condition');
}
foreach ($reportChilds as $report) {
$classReport = 'PHP_CompatInfo_Report_' . ucfirst($report);
new $classReport($source, $options, $allWarnings, $reportResults);
}
echo PHP_EOL;
if (count($allWarnings) > 0 && $options['verbose'] > 0) {
echo 'Warning messages : (' . count($allWarnings) . ')' . PHP_EOL;
echo PHP_EOL;
foreach ($allWarnings as $warn) {
if (in_array($warn, $warnings)) {
// other listeners need to be notifed about console warnings
$pci->addWarning($warn);
}
echo ' ' . $warn . PHP_EOL;
}
echo PHP_EOL;
}
if (class_exists('PHP_Timer', true) === true) {
echo PHP_Timer::resourceUsage() . PHP_EOL;
echo PHP_EOL;
}
echo 'Required PHP ' . $masterResults['versions'][0] . ' (min)';
if (!empty($masterResults['versions'][1])) {
echo ', ' . $masterResults['versions'][1] . ' (max)';
}
echo PHP_EOL;
}
示例8: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
if (\App::environment() === 'production') {
$this->error('This feature is not available on this server');
}
$process = new Process('apidoc -i ' . base_path('app/Http/Controllers') . ' -o ' . base_path('apidoc'));
$process->run();
if (!$process->isSuccessful()) {
$this->error('Impossible to generate doc');
$this->error($process->getErrorOutput());
$this->info('You need to install apidoc: (sudo) npm install apidoc -g');
return;
}
$this->info($process->getOutput());
$this->comment('Documentation generated in folder ' . base_path('doc'));
$this->comment(\PHP_Timer::resourceUsage());
}
示例9: execute
/**
* Executes the current command.
*
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
* @return null|int null or 0 if everything went fine, or an error code
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$finder = new FinderFacade($input->getArgument('values'), $input->getOption('exclude'), $this->handleCSVOption($input, 'names'), $this->handleCSVOption($input, 'names-exclude'));
$files = $finder->findFiles();
if (empty($files)) {
$output->writeln('No files found to scan');
exit(1);
}
$quiet = $output->getVerbosity() == OutputInterface::VERBOSITY_QUIET;
$detector = new Detector();
$result = $detector->detectDeadCode($files, $input->getOption('recursive'));
if (!$quiet) {
$printer = new Text();
$printer->printResult($output, $result);
$output->writeln(\PHP_Timer::resourceUsage());
}
}
示例10: execute
/**
* Executes the current command.
*
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
* @return null|int null or 0 if everything went fine, or an error code
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$database = new Database($input->getArgument('database'));
$repository = $input->getArgument('repository');
$quiet = $output->getVerbosity() == OutputInterface::VERBOSITY_QUIET;
$finder = new FinderFacade(array($repository), $input->getOption('exclude'), $this->handleCSVOption($input, 'names'), $this->handleCSVOption($input, 'names-exclude'));
$progressHelper = null;
if ($input->getOption('progress')) {
$progressHelper = $this->getHelperSet()->get('progress');
}
$processor = new Processor($repository, $database, $finder, $output, $progressHelper);
$processor->process();
if ($input->getOption('progress')) {
$progressHelper->finish();
$output->writeln('');
}
if (!$quiet) {
$output->writeln(\PHP_Timer::resourceUsage());
}
}
示例11: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
\Log::info('Assets::Clean cleaning build assets');
$baseAssetsPath = base_path('public/assets/');
if (!is_dir($baseAssetsPath)) {
$this->warn(sprintf("Folder %s does not exists", $baseAssetsPath));
return;
}
if ($handle = opendir($baseAssetsPath)) {
while (false !== ($entry = readdir($handle))) {
$path = $baseAssetsPath . '/' . $entry;
if ($entry != "." && $entry != ".." && is_dir($path)) {
$this->info('Delete public/assets/' . $entry);
$this->deleteDir($path);
}
}
closedir($handle);
}
$this->comment(\PHP_Timer::resourceUsage());
}
示例12: execute
protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{
$configFile = $input->getArgument('config');
if (!$configFile) {
throw new \Exception('Config argument needed');
}
$filesystem = new FilesystemAccess(null);
$config = new Config($filesystem);
$config->loadConfig($configFile);
$config = $config->getConfig();
$config->folders->root = realpath($config->folders->root);
$filesystem->setRoot($config->folders->root);
$directoryScanner = new DirectoryScanner($filesystem, $config->folders->root);
foreach ($config->folders->include as $include) {
$directoryScanner->includeDirectory($include);
}
foreach ($config->folders->exclude as $exclude) {
$directoryScanner->excludeDirectory($exclude);
}
foreach ($config->filetypes->include as $include) {
$directoryScanner->includeFiletype($include);
}
foreach ($config->filetypes->exclude as $exclude) {
$directoryScanner->excludeFiletype($exclude);
}
$files = $directoryScanner->getFiles();
$outputClass = new ChainedOutput($output);
foreach ($config->output as $outputConfiguration) {
$outputClass->addOutputClass($outputConfiguration->class, $outputConfiguration->parameter);
}
$classScanner = new ClassScanner($filesystem, $config->folders->root, $config->vendor, $outputClass);
$classModifier = new NamespaceDependencyChecker($filesystem, $classScanner, $config->vendor, $config->folders->root, $outputClass);
$classModifier->analyze($files);
$outputClass->printAll();
$outputClass->writeln(\PHP_Timer::resourceUsage());
if ($classScanner->foundError || $classModifier->foundError) {
return 1;
} else {
return 0;
}
}
示例13: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
\Log::info('Assets::Update Run bower update');
$this->info("Update bower assets");
$process = new Process('bower update --allow-root');
$process->run(function ($type, $buffer) {
if ('err' === $type) {
$this->error($buffer);
} else {
$this->info($buffer);
}
});
if (!$process->isSuccessful()) {
$this->error('Impossible to update bower');
$this->error($process->getErrorOutput());
}
$this->info("Remove useless local bower package");
$process = new Process('bower prune --allow-root');
$process->run();
$this->comment(\PHP_Timer::resourceUsage());
}
示例14: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->info("Build assets");
$cmd = sprintf('node ./node_modules/gassetic/bin.js %s --env=%s', $this->getGasseticArgument(), $this->getEnv());
$this->info($cmd);
$process = new Process($cmd);
$process->setTimeout($this->option('watch') ? 86400 : 30);
$process->run(function ($type, $buffer) {
// prevent double line break
$buffer = str_replace("\n", "", $buffer);
if ('err' === $type) {
$this->error($buffer);
} else {
$this->info($buffer);
}
});
if (!$process->isSuccessful()) {
$this->error($process->getErrorOutput());
}
$this->comment(\PHP_Timer::resourceUsage());
}
示例15: execute
/**
* Executes the current command.
*
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
* @return null|integer null or 0 if everything went fine, or an error code
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$finder = new FinderFacade($input->getArgument('values'), $input->getOption('exclude'), $this->handleCSVOption($input, 'names'), $this->handleCSVOption($input, 'names-exclude'));
$files = $finder->findFiles();
if (empty($files)) {
$output->writeln('No files found to scan');
exit(1);
}
$progressHelper = null;
if ($input->getOption('progress')) {
$progressHelper = $this->getHelperSet()->get('progress');
$progressHelper->start($output, count($files));
}
$strategy = new DefaultStrategy();
$detector = new Detector($strategy, $progressHelper);
$quiet = $output->getVerbosity() == OutputInterface::VERBOSITY_QUIET;
$clones = $detector->copyPasteDetection($files, $input->getOption('min-lines'), $input->getOption('min-tokens'), $input->getOption('fuzzy'));
if ($input->getOption('progress')) {
$progressHelper->finish();
$output->writeln('');
}
if (!$quiet) {
$printer = new Text();
$printer->printResult($output, $clones);
unset($printer);
}
$logPmd = $input->getOption('log-pmd');
if ($logPmd) {
$pmd = new PMD($logPmd);
$pmd->processClones($clones);
unset($pmd);
}
if (!$quiet) {
print \PHP_Timer::resourceUsage() . "\n";
}
if (count($clones) > 0) {
exit(1);
}
}