X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fresourceloader%2FResourceLoader.php;h=36bf6567b92a19f88b16faf71d0d6df50537f6da;hp=ad16420651c8d3a13ba99559bd283b3cf8a81626;hb=9f8a8868677b2ebe32f6103fa2b1b001207f16ff;hpb=fb4821adfc3ab95d9c5c0be1162139f99bfebf6c diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php index ad16420651..36bf6567b9 100644 --- a/includes/resourceloader/ResourceLoader.php +++ b/includes/resourceloader/ResourceLoader.php @@ -26,8 +26,8 @@ use MediaWiki\MediaWikiServices; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; -use WrappedString\WrappedString; use Wikimedia\Rdbms\DBConnectionError; +use Wikimedia\WrappedString; /** * Dynamic JavaScript and CSS resource loading system. @@ -236,8 +236,6 @@ class ResourceLoader implements LoggerAwareInterface { return $data; } - /* Methods */ - /** * Register core modules and runs registration hooks. * @param Config $config [optional] @@ -655,7 +653,7 @@ class ResourceLoader implements LoggerAwareInterface { * * @since 1.26 * @param ResourceLoaderContext $context - * @param string[] $modules List of known module names + * @param string[] $moduleNames List of known module names * @return string Hash */ public function getCombinedVersion( ResourceLoaderContext $context, array $moduleNames ) { @@ -692,7 +690,6 @@ class ResourceLoader implements LoggerAwareInterface { * * @since 1.28 * @param ResourceLoaderContext $context - * @param string[] $modules List of module names * @return string Hash */ public function makeVersionQuery( ResourceLoaderContext $context ) { @@ -728,6 +725,8 @@ class ResourceLoader implements LoggerAwareInterface { // See https://bugs.php.net/bug.php?id=36514 ob_start(); + $this->measureResponseTime( RequestContext::getMain()->getTiming() ); + // Find out which modules are missing and instantiate the others $modules = []; $missing = []; @@ -828,6 +827,16 @@ class ResourceLoader implements LoggerAwareInterface { echo $response; } + protected function measureResponseTime( Timing $timing ) { + DeferredUpdates::addCallableUpdate( function () use ( $timing ) { + $measure = $timing->measure( 'responseTime', 'requestStart', 'requestShutdown' ); + if ( $measure !== false ) { + $stats = MediaWikiServices::getInstance()->getStatsdDataFactory(); + $stats->timing( 'resourceloader.responseTime', $measure['duration'] * 1000 ); + } + } ); + } + /** * Send main response headers to the client. * @@ -1198,8 +1207,6 @@ MESSAGE; return $moduleNames; } - /* Static Methods */ - /** * Return JS code that calls mw.loader.implement with given module properties. *