Manual:Profiling

To get more detail, you need to enable profiling. Profiling tracks code execution during a page action and reports back the percentage of total code execution that was spent in any specific function. The generated profile only includes functions that have specifically been marked to be profiled. Note that you have to set  in LocalSettings; this is the file, to which your profiling data will be appended.

If you are not using profiling, but have a  file in the MediaWiki root folder, you may receive errors referring to. Deleting, or renaming, the  file will resolve this error. The  file, also in the MediaWiki root folder, can serve as a template should you enable profiling in the future.

To enable profiling, you need to modify the  (see   in the MediaWiki root folder for an example). By default the file includes a  which just dumps profiling information. To instead direct this information to a file, edit StartProfiler.php so that it looks like this:

Then you can customize profiling options in  (not  ; be sure to edit beneath the requirement of  ).

Common configuration (both <1.7 and >1.8):

In MediaWiki 1.7 and earlier, instead of editing, you have to set   to. This will generate basic page timing information in the file defined by.

In addition to the settings list above, these additional settings are available:

Advanced profiling
Once you have enabled profiling, you can trace code execution through any function that you want to investigate as a bottleneck by wrapping the function with the following code:

After you've added this information, browse to a page in the wiki. This will generate profiling info in the log file you defined above. Change  in   to true or false for different display formats.

Logging to Database
To log profiling information to a database, set  in LocalSettings.php. Then either run update.php (since 1.21) and the profiling table will be added or manually apply the file maintenance/archives/patch-profiling.sql (the recommended way to do this is ).

Viewing Profile Info
If you log your profiling information to the database, you can view the information in a webpage by browsing to. You must also set in   (  for MediaWiki < 1.16). Then, after gathering data by browsing wiki pages, visit  to see how much time your profiled code is using and how many times it's being called.

To view profiling information as HTML comments appended to the bottom of a page, just add  to the URL. This feature is not in the standard product, you can enable it by adding this to :