MediaWiki extension PerformanceInspector

Clone this repo:
  1. 2974014 build: Updating mediawiki/mediawiki-phan-config to 0.15.0 by libraryupgrader · 3 weeks ago master
  2. 970d088 build: Updating nanoid to 3.3.8 by libraryupgrader · 4 weeks ago
  3. 2e36723 build: Updating cross-spawn to 7.0.6 by libraryupgrader · 6 weeks ago
  4. d4cf0d3 build: Updating mediawiki/mediawiki-codesniffer to 45.0.0 by libraryupgrader · 9 weeks ago
  5. 36157f3 build: Updating micromatch to 4.0.8 by libraryupgrader · 5 months ago

PerformancInspector

The PerformanceInspector is a extension for mediawiki, to make it easier for editors to find potential performance problems. You can read more about the extension at https://www.mediawiki.org/wiki/Extension:PerformanceInspector.

How it works

The extension has a startup module; when activated it adds a link to the tools menu. When you start the tool it will run the collectors, parse the data against the view templates and display everything in a dialog.

The details

The most important part of the inspector is the collectors. A collector collects metrics/data from different part of the system and makes it available in a dialog for the user.

A collector

There's a couple of things a collector needs to do.

The collector needs to add a function to the collectors array, that will run when the data is collected. It happens when the user activates the inspector.

That function needs to return a Promise/value that have the following structure:

There's one extra bonus thing. The postProcess function that if it exists, will run after the template has been merged, passing the parsed HTML as a parameter, making it possible to manipulate the outcome by Javascript (for graphs etc).

Summary section

The summary data will be merged together with the summary.mustache template and put on top of the result page. Every collector can add to the summary and it's all merged with the same template. If you want to add information to the summary section, you change the template.

Message handling

The mustache templates are parsed together with the data passed by the collector and the mw.msg function. In the mustache template you can get a message by using the key msg:

Adding a new collector

There's three steps that you need to do:

  • Create your collector in modules/collectors/ (and make sure you follow the structure of a collector).
  • Add the template for the collector in modules/templates
  • If you want add data to the summary section, change the summary.mustache template to include the data you pass.
  • Add your script to extension.js in the analyze module ext.PerformanceInspector.analyze
  NODES
Javascript 1
os 4