Module:Sandbox/Aidan9382/Benchmarker/doc

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

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.

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%)