Board Thread:Watercooler/@comment-5590118-20150701035141/@comment-11733175-20150709144513

Your first link is for string functions and more complex templates that used a number of parser functions. As you'll notice, I agreed string functions were likely faster in lua and I know lua was used to try and alleviate the issues of complicated templates using lots of parser functions.

It is true using #invoke is faster than sending it through a template first. This is because every time a page is transcluded/invoked it creates a particular type of call in the code that is considered expensive. It's why there are limits to template expansion depth and why there is a limit to how many #ifexist can be called on a single page. However, there comes a time when using a template is more user friendly to edit. I can't remember the last time I saw a parser function being used directly on a page because they are almost universally deemed more complicated than templates.

The notion that #if is slower than a module that does the same is actually false, as noted in the second link as #invoke runs at ~600/second where as parser functions such as #if, ifeq, etc. run at ~1250/second. This is likely the same for the other 'core' parser functions as listed in mw:Help:Extension:ParserFunctions. I cannot comment explicitly on #switch's performance due to the lack of data, but I suspect you don't have any data to prove that the module is more efficient anyway. The performance gains come from when multiple parser functions are used at the same time. As an example, using two #if calls is roughly the same as using one #invoke. But if that #invoke contains two conditionals then it could potentially be faster. The performance gains will obviously increase as there are more parser functions in the template.

My overall point is creating modules to directly replace parser functions is counter-productive and confusing.