WikiQueer:Lua speed

This essay, WQ:Lua speed, explains various issues about the execution speed and performance of Lua script in WikiQueer. The speed of using Lua modules can vary greatly, compared to markup-based templates, often ranging from 4x-8x times faster, or 180,000x faster when scanning text strings, which can exceed the 500-character parser-function markup limit as 64,000 characters or more. For specific Lua performance, it really depends on how many parameters are being used, and how deep the nested logic runs. Also, optimization techniques could be used to make Lua run even faster.

Numerous tests of the Lua-based WQ:CS1 cite templates, each processing over 430 possible parameter names, have clocked as 6x-7x faster, when formatting 80-110 cite templates per second. However, the maximum speed there seems to show Lua could be ~8x faster than markup to format simple parameters. Meanwhile, tests of Lua-based string-scans, or even extracting a final character by "string.sub(mytext,-1,-1)" can run thousands of times faster, and exceed the markup string limit of 500 length by searching whole sections of wikitext exceeding 64,000 characters in length.

When speed is critical, invoking a small Lua function directly can be 50% faster than using the related shell template:
 * Lua-based Template:Str_len runs ~250/second
 * Lua function Module:String|len runs ~400/second

It is 50% faster to use to invoke the short Lua function "len" in Module:String, and also reduces the expansion depth from 3 levels to 2 levels.

Some related speed figures:
 * Many parser functions run at ~750 per second (such as: )
 * Short templates run at hundreds per second.
 * Character-insertion templates can run at 2,400 per second, such as.
 * Top infoboxes (for settlements) can format in ~1-2 seconds.
 * Bottom navboxes format at 2-3 per second, but double page size.
 * Markup-based CS1 cites run 20/second (with Template:Citation/core).
 * Template:Convert runs 30/second, despite hundreds of possible unit codes.

In fact, {Convert} has been an interesting case with expansion-depth as the major problem, not speed, because articles often have fewer than 7 conversions (a quarter second), but the depth of {Convert} has often been 19-29 levels deep. Hence, within double-nested infoboxes, {Convert} has often exceeded the WQ:expansion depth limit. For Lua-based templates, the expansion depth is typically 3 levels deep. -Wikid77 (talk) 15:49, 24 February 2013 (UTC)