X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2Fbenchmarks%2FbenchmarkParse.php;h=1753250bcd75a5d5982a23e3cad0df93b83d4fc3;hb=892b17237bb44630fa6f508c5bf85374a62def13;hp=0a89bfa558020fbb0f1d0c13a228c8342a870421;hpb=2f885ee6b797e5a176ce7b270b674a04b5945b06;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/benchmarks/benchmarkParse.php b/maintenance/benchmarks/benchmarkParse.php index 0a89bfa558..1753250bcd 100644 --- a/maintenance/benchmarks/benchmarkParse.php +++ b/maintenance/benchmarks/benchmarkParse.php @@ -24,6 +24,8 @@ require __DIR__ . '/../Maintenance.php'; +use MediaWiki\MediaWikiServices; + /** * Maintenance script to benchmark how long it takes to parse a given title at an optionally * specified timestamp @@ -34,6 +36,13 @@ class BenchmarkParse extends Maintenance { /** @var string MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS) */ private $templateTimestamp = null; + private $clearLinkCache = false; + + /** + * @var LinkCache + */ + private $linkCache; + /** @var array Cache that maps a Title DB key to revision ID for the requested timestamp */ private $idCache = []; @@ -52,6 +61,8 @@ class BenchmarkParse extends Maintenance { 'Use templates which were current at the given time (except that moves and ' . 'deletes are not handled properly)', false, true ); + $this->addOption( 'reset-linkcache', 'Reset the LinkCache after every parse.', + false, false ); } function execute() { @@ -60,6 +71,10 @@ class BenchmarkParse extends Maintenance { Hooks::register( 'BeforeParserFetchTemplateAndtitle', [ $this, 'onFetchTemplate' ] ); } + $this->clearLinkCache = $this->hasOption( 'reset-linkcache' ); + // Set as a member variable to avoid function calls when we're timing the parse + $this->linkCache = MediaWikiServices::getInstance()->getLinkCache(); + $title = Title::newFromText( $this->getArg() ); if ( !$title ) { $this->error( "Invalid title" ); @@ -118,7 +133,7 @@ class BenchmarkParse extends Maintenance { * @return bool|string Revision ID, or false if not found or error */ function getRevIdForTime( Title $title, $timestamp ) { - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $id = $dbr->selectField( [ 'revision', 'page' ], @@ -144,6 +159,9 @@ class BenchmarkParse extends Maintenance { function runParser( Revision $revision ) { $content = $revision->getContent(); $content->getParserOutput( $revision->getTitle(), $revision->getId() ); + if ( $this->clearLinkCache ) { + $this->linkCache->clear(); + } } /**