Module:Sandbox/Aidan9382/Benchmarker/doc
| This is a documentation subpage for Module:Sandbox/Aidan9382/Benchmarker. It may contain usage information, categories and other content that is not part of the original module page. |
| This module is rated as alpha. It is ready for limited use and third-party feedback. It may be used on a small number of pages, but should be monitored closely. Suggestions for new features or adjustments to input and output are welcome. |
A module benchmarker aimed at benchmarking at a wider scope and reliably. This differs from the standard MediaWiki Lua Profile in that it profiles specifically exported module functions instead of every function (e.g. standard string library functions). This lets you figure out what module is making expensive calls rather than what expensive calls are being made.
Usage
[edit source]To benchmark a module and all submodules it calls, put local __prepare = require("Module:Sandbox/Aidan9382/Benchmarker") on the first line and __prepare(p, "<Module name>") (or the equivilant to p) at the very bottom just before the return in the highest level module you want to benchmark from. You do not need to include the benchmarker in any other modules; any module fetched using require will automatically have its returned value hooked.
Example output
[edit source]-- Benchmarker Finished -- Total time taken: 91.1ms Top 5 modules by time taken: Module:Pagetype/sandbox: 55.7ms (61.1%) Module:Wikitext Parsing: 25.5ms (28%) Module:WikiProject banner/sandbox: 7.8ms (8.6%) Module:Template parameter value: 1.9ms (2.1%) Module:Arguments: 0.2ms (0.2%) Top 5 functions by time taken: Module:Pagetype/sandbox._main: 55.7ms (61.1%) Module:Wikitext Parsing.PrepareText: 25.5ms (28%) Module:WikiProject banner/sandbox._main: 7.4ms (8.1%) Module:Template parameter value.getValue: 1ms (1.1%) Module:Template parameter value.getTemplate: 1ms (1.1%)