User:Dragons flight/Lua performance

Since initial deployment, a little more than a month ago, enwiki has converted several dozen templates to use Lua (e.g. Category:Lua-based templates). The following is a summary of real world performance testing conducted on enwiki to compare the time required for rendering both the old and new versions.

Testing procedure
For each template reported below, a test page was generated that called the template repeatedly (typically a few hundred times), using varied input taken from either lists of test cases or real world pages. These pages were loaded using Mediawiki's "preview" function and the time required was measured via the "served by" comment in the HTML source of the rendered preview. This previewing was repeated five times and the results averaged. In addition, the time required to preview a blank page was subtracted from the total to isolate the effect of the templates. Lastly, the total time was divided by the number of template iterations to derive a time per iteration. This procedure was repeated with both old and new versions of the template to measure the impact of introducing Lua.

Updated: Tests were rerun and numbers updated May 18, 2013.

Results
In addition, testing done with a dummy Lua module that takes one parameter and does nothing estimated that the Mediawiki overhead per Lua #invoke call is approximately 2.0 ms. Consequently, for functions like rnd and str find, a majority of the execution time is actually devoted to the parser overhead associated with launching a Lua #invoke call. For the important case of citation templates, the overhead appears to be approximately 25% of the run time.