X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fresourceloader%2FResourceLoader.php;h=36bf6567b92a19f88b16faf71d0d6df50537f6da;hp=c58bb00b942ec8273cfe0ed2ca676e26dc8e508a;hb=9f8a8868677b2ebe32f6103fa2b1b001207f16ff;hpb=3e88f9fa2a5a00bc1330560accf8e9d09c8be42a diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php index c58bb00b94..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] @@ -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. *