MediaWiki-Docker/Configuration recipes/Profiling

From mediawiki.org
Jump to navigation Jump to search

Performance profiling with XHProf[edit]

MediaWiki-Docker comes with php-tideways pre-installed, which provides XHProf support for profiling web requests and maintenance scripts.

LocalSettings.php
// Use ?forceprofile=1 to profile the request.
// Output is added to the end of the response (use view-source if the response is HTML).
if ( extension_loaded( 'tideways_xhprof' ) ) {
	if ( isset( $_GET['forceprofile'] ) || PHP_SAPI === 'cli' ) {
		$wgProfiler = [
			'class'  => ProfilerXhprof::class,
			'flags'  => TIDEWAYS_XHPROF_FLAGS_CPU | TIDEWAYS_XHPROF_FLAGS_NO_BUILTINS,
			'output' => 'text',
		];
	}
}