Overview
This module provides a possible implementation of {{convert}}. Associated pages are:
- Template:Convert/sandboxlua – template which invokes the module
- Template:Convert/testcases – template tests
- Module:Convert – module to convert units
- Module:Convert/data – module with unit definitions, used by #3
- User:Johnuniq/Conversion data – master list of unit definitions
- User:Johnuniq/Making the units table – program to translate #5 to #4
- Template talk:Convert#Lua Module:Convert – some notes about plans
Usage examples:
{{convert/sandboxlua|5.2|m|ftin}}
→ 5.2 metres (17 ft 1 in){{convert/sandboxlua|5+3/8|in}}
→ 5+3⁄8 inches (140 mm){{convert/sandboxlua|60|x|120|m|ft}}
→ 60 by 120 metres (200 ft × 390 ft)
Currently, the real master list of unit definitions is a text file on my computer (I have a script to convert that text file to the wikitext used at #5). The uniformly formatted text file is easier for making bulk changes, but will be discarded when the module nears completion.
In addition to the test page (#2 above), I run a test program on my local system that feeds hundreds of tests into the module.
Module:Convert has many issues to be fixed, and some features that need to be implemented. It does not support inputs with multiple units, such as 3 ft 6 in
, and does not support large scale units like e3km
. Complex units like the hand
unit of length have not been implemented, and there are hundreds of unit codes that are not yet defined (the units which are defined are listed at #5).
I want to use this section to document what the module is about, and will update the above if needed. Johnuniq (talk) 04:08, 3 March 2013 (UTC)
Plans
I will put an outline of short-term plans here, including possible performance improvements. The following is to remind me what to include.
- Big table Hideous trick to speed up loading a large table.
- mw.loadData To load a read-only table only once per page; should be deployed at test2 this Monday, and at enwiki a week after that.
Discussion
My following comment was in "Overview" above; moved to here to keep the overview brief. Some interesting performance challenges exist. The "NewPP limit report" in the html source for this test page says "Lua time usage: 0.295s". Johnuniq (talk) 09:35, 19 February 2013 (UTC)
- presuming that a page that requires data conversion might require many of them, and consideing the sheer size of Module:Convert/data, you might want to look at the mw.loadData documentaion and see if you can use this to improve performance. peace - קיפודנחש (aka kipod) (talk) 16:45, 2 March 2013 (UTC)
- Mentioned at http://test2.wikipedia.org/wiki/User:Johnuniq -- WOSlinker (talk) 17:13, 2 March 2013 (UTC)
- presuming that a page that requires data conversion might require many of them, and consideing the sheer size of Module:Convert/data, you might want to look at the mw.loadData documentaion and see if you can use this to improve performance. peace - קיפודנחש (aka kipod) (talk) 16:45, 2 March 2013 (UTC)
- Thanks, but this page is a little out of date, and I will update it with the info that WOSlinker linked to. My comment about "performance challenges" was written when I had not absorbed the fact that some testcase timeouts were due to use of
frame:preprocess
. It actually looks as if Module:Convert is reasonably fast, although I haven't yet hammered it. In my sandbox, there are 122 calls of {{convert/sandboxlua}}, and the HTML source shows the Lua time usage is 0.348s (2.8 ms per call). That makes me think that Lua is fast enough even with the current bloated modules. Nevertheless, I'm thinking of some ways I could improve performance and will update the "Plans" section above with info, possibly within a few hours. Johnuniq (talk) 04:08, 3 March 2013 (UTC)
- Thanks, but this page is a little out of date, and I will update it with the info that WOSlinker linked to. My comment about "performance challenges" was written when I had not absorbed the fact that some testcase timeouts were due to use of