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


PHP ParserOutput::getPerformanceStats方法代码示例

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


在下文中一共展示了ParserOutput::getPerformanceStats方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onArticleViewAfterParser

 public static function onArticleViewAfterParser(Article $article, ParserOutput $parserOutput)
 {
     global $wgCityId, $wgDBname;
     // we collect production data from Oasis only
     /*
     $app = F::app();
     if ( !$app->checkSkin( 'oasis', $app->wg->Skin )
     		|| $app->wg->DevelEnvironment || $app->wg->StagingEnvironment ) {
     	return true;
     }
     */
     if (class_exists('WScribeClient')) {
         try {
             $title = $article->getTitle();
             $fields = array('wikiId' => intval($wgCityId), 'databaseName' => $wgDBname, 'articleId' => $title->getArticleID(), 'namespaceId' => $title->getNamespace(), 'articleTitle' => $title->getText(), 'parserTime' => $parserOutput->getPerformanceStats('time'), 'wikitextSize' => $parserOutput->getPerformanceStats('wikitextSize'), 'htmlSize' => $parserOutput->getPerformanceStats('htmlSize'), 'expFuncCount' => $parserOutput->getPerformanceStats('expFuncCount'), 'nodeCount' => $parserOutput->getPerformanceStats('nodeCount'), 'postExpandSize' => $parserOutput->getPerformanceStats('postExpandSize'), 'tempArgSize' => $parserOutput->getPerformanceStats('tempArgSize'));
             $data = json_encode($fields);
             WScribeClient::singleton(self::SCRIBE_KEY)->send($data);
         } catch (TException $e) {
             Wikia::log(__METHOD__, 'scribeClient exception', $e->getMessage());
         }
     }
     // Logging parser activity for monitoring
     // wiki and article info are sent to logstash anyways so no need to repeat them here
     WikiaLogger::instance()->info("Parser execution", ['parser-time' => round($parserOutput->getPerformanceStats('time') * 1000), 'node-count' => (int) $parserOutput->getPerformanceStats('nodeCount'), 'wikitext-size' => (int) $parserOutput->getPerformanceStats('wikitextSize'), 'skin-name' => RequestContext::getMain()->getSkin()->getSkinName()]);
     return true;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:26,代码来源:ParserSpeedHooks.class.php

示例2: onArticleViewAddParserOutput

 /**
  * Hook handler. Sets a "size category" attribute based on the article that is displayed
  *
  * @param Article $article
  * @param ParserOutput $parserOutput
  * @return bool true (hook handler)
  */
 public static function onArticleViewAddParserOutput(Article $article, ParserOutput $parserOutput)
 {
     $wikitextSize = $parserOutput->getPerformanceStats('wikitextSize');
     $htmlSize = $parserOutput->getPerformanceStats('htmlSize');
     $expFuncCount = $parserOutput->getPerformanceStats('expFuncCount');
     $nodeCount = $parserOutput->getPerformanceStats('nodeCount');
     if (!is_numeric($wikitextSize) || !is_numeric($htmlSize) || !is_numeric($expFuncCount) || !is_numeric($nodeCount)) {
         return true;
     }
     if ($wikitextSize < 3000 && $htmlSize < 5000 && $expFuncCount == 0 && $nodeCount < 100) {
         $sizeCategory = self::SIZE_CATEGORY_SIMPLE;
     } elseif ($wikitextSize < 30000 && $htmlSize < 50000 && $expFuncCount <= 4 && $nodeCount < 3000) {
         $sizeCategory = self::SIZE_CATEGORY_AVERAGE;
     } else {
         $sizeCategory = self::SIZE_CATEGORY_COMPLEX;
     }
     Transaction::setAttribute(Transaction::PARAM_SIZE_CATEGORY, $sizeCategory);
     return true;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:26,代码来源:Transaction.php


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