Module:Timing/doc: Difference between revisions

Content deleted Content added
Line 137:
</pre>
 
EvenAlso this wrapper is quite heavy compared to the tested function. We dropped getting the current frame in the previous timing calls, but the run time is still 10 times higher than the bare callitself.
 
In general you should precompute as much as possible to avoid unnecessary computations inside the loop, like this
<source lang="Lua">
my_object = {};
 
my_object.hello = function( frame )
local str = "Hello World!"
return str
end
 
my_object.frame = mw.getCurrentFrame()
my_object.wrap = function ()
return my_object.hello(my_object.frame)
end
 
return my_object
</source>
 
===Testing in a sandboxed environment===