Module talk:Convert: Difference between revisions

Content deleted Content added
m fix links for moved module
update to show current results
Line 1:
==Overview==
This module provides a possiblean implementation of <nowiki>{{tl|convert}}</nowiki>. Associated pages are:
#[[Template:Convert/sandboxlua]] – template which invokes the module
#[[Template:Convert/testcases]] – template tests (see below)
#[[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/Archive February 2013#Lua Module:Convert|Talk archive]] – someAnnouncement of module at [[Template talk:Convert]] notesin aboutFebruary plans2013
 
Usage examples:
*<code><nowiki>{{convert/sandboxlua|5.2|m|ftin}}</nowiki></code> → {{convert/sandboxlua|5.2|m|ftin}}
*<code><nowiki>{{convert/sandboxlua|5+3/8|in}}</nowiki></code> → {{convert/sandboxlua|5+3/8|in}}
*<code><nowiki>{{convert/sandboxlua|6|ft|3|in|hand}}</nowiki></code> → {{convert/sandboxlua|6|ft|3|in|hand}}
*<code><nowiki>{{convert/sandboxlua|60|x|120|m|ft}}</nowiki></code> → {{convert/sandboxlua|60|x|120|m|ft}}
*<code><nowiki>{{convert/sandboxlua|1|e12BTU/cuft|e9kJ/L|lk=on}}</nowiki></code> → {{convert/sandboxlua|1|e12BTU/cuft|e9kJ/L|lk=on}}
 
The [[Template:Convert/testcases|testcases]] show good agreement between the templates and the module. There are some minor rounding and other differences, and the only significant disagreements appear to be problems in the templates. Substantive differences occur at:
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.
*[[Template:Convert/testcases/bytype/energy2|energy2]]: different default output for in.lbf
*[[Template:Convert/testcases/bytype/energypervolume|energypervolume]]: template problems
*[[Template:Convert/testcases/bytype/exhaustemission|exhaustemission]]: template problem
*[[Template:Convert/testcases/bytype/length2|length2]]: different micro sign (should be "µ" U+00B5, not "μ" GREEK SMALL LETTER MU U+03BC)
*[[Template:Convert/testcases/bytype/mole|mole]]: different micro sign
*[[Template:Convert/testcases/bytype/power|power]]: calorie disagreements
*[[Template:Convert/testcases/bytype/time|time]]: module cannot handle unit horse year (unit not used)
*[[Template:Convert/testcases/bytype/torque|torque]]: template problems and minor differences
*[[Template:Convert/testcases/bytype/volume|volume]]: template hectolitre problems
*[[Template:Convert/testcases/bytype/misc|misc]]: module cannot handle units note, spanner, wrench (units not used)
 
The module appears to correctly implement the main features of the template. There are some minor disagreements concerning rounding of results, and some units and options have not yet been implemented. More testing is needed. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 10:52, 26 April 2013 (UTC)
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 {{nowrap|<code>3 ft 6 in</code>}}, and does not support large scale units like <code>e3km</code>. Complex units like the <code>hand</code> 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. [[User:Johnuniq|Johnuniq]] ([[User talk: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.
*[http://test2.wikipedia.org/wiki/User:Johnuniq#Big_tables Big table] Hideous trick to speed up loading a large table.
*[http://test2.wikipedia.org/wiki/User:Johnuniq#mw.loadData 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.
[[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 04:08, 3 March 2013 (UTC)
 
==Discussion==
<small>My following comment was in "Overview" above; moved to here to keep the overview brief.</small> Some interesting performance challenges exist. The "NewPP limit report" in the html source for this [[Template:Convert/testcases/bytype/force|test page]] says "Lua time usage: 0.295s". [[User:Johnuniq|Johnuniq]] ([[User talk: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:Extension:Scribunto/Lua_reference_manual#mw.loadData|mw.loadData documentaion]] and see if you can use this to improve performance. peace - [[User:קיפודנחש|קיפודנחש (aka kipod)]] ([[User talk:קיפודנחש|talk]]) 16:45, 2 March 2013 (UTC)
:::Mentioned at http://test2.wikipedia.org/wiki/User:Johnuniq -- [[User:WOSlinker|WOSlinker]] ([[User talk:WOSlinker|talk]]) 17:13, 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 <code>frame:preprocess</code>. It actually looks as if Module:Convert is reasonably fast, although I haven't yet hammered it. In [[User:Johnuniq/sandbox|my sandbox]], there are 122 calls of {{tl|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. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 04:08, 3 March 2013 (UTC)
{{od|3}}I've removed the plans as they were obsolete. Also, while the testcase pages require a significant time to render, the convert module appears to be sufficiently fast, so there is no reason to look for ways to speed it up. I now have 1689 calls in [[User:Johnuniq/sandbox|my sandbox]], and the Lua time usage is about 1 millisecond per convert. There is a per-page overhead, and it looks like a small number of converts takes around 40&nbsp;ms total. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 10:52, 26 April 2013 (UTC)