Content deleted Content added
Line 46:
Note that this function is very simple, and therefore the run time for the function gets close to the run time for the baseline. As a result the run time for each set gets close to the standard deviation.
=== Testing with arguments ===
The test call can take additional arguments. It will pass those on unaltered to the function under test. Most important, they are ''not'' cloned, that is they are passed on as is, and therefore if the function under test alters them then errors will accumulate. This can happen for the types ''function'', ''table'', ''userdata'' and ''thread''. We don't use ''userdata'' and ''thread'' on Wikipedia. That leaves ''nil'', ''boolean'', ''number'' and ''string'' as passed by value and safe against changes.
Strings are really pass by reference, but they are immutable and has copy on write.
A common example on how to pass in an argument is how to do this for the current frame
<source lang="Lua">
=require 'Module:Timing'(p.hello, mw.getCurrentFrame())
</source>
This produce the following output
<pre>
=require 'Module:Timing'(p.hello, mw.getCurrentFrame())
Each call was running for about 7.0810000000025E-9 seconds.
Mean runtime for each set was 7.0810000000025E-7 seconds,
with standard deviation of 4.2284471144874E-7 seconds,
minimum 9.3910000000001E-6, maximum 1.0276E-5.
Total time spent was about 0.000258046 seconds.
</pre>
Using arguments like this does not impose very much additional load, and most of it can be factored out.
=== Testing with a wrapper function ===
Line 66 ⟶ 89:
=require 'Module:Timing'(wrap)
Each call was running for about 3.48499E-7 seconds.
</pre>
Line 103 ⟶ 126:
=require 'Module:Timing'(p.wrap)
Each call was running for about 1.91509E-7 seconds.
</pre>
|