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.
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 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.
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).
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.
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:
There's three steps that you need to do: