Module:Timing: Difference between revisions

Content deleted Content added
a little too fast
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1:
-- module timing individual functions
-- @license (CC-BY-SA-3.0)
-- © John Erling Blad, Creative Commons by Attribution 3.0
-- @copyright John Erling Blad <jeblad@gmail.com>
 
-- @var The table holding this modules exported members
Line 111 ⟶ 112:
}
return table.concat(strings, '')
end
 
-- a dummy function that is used for a baseline measure
-- @return nil
function dummyp.nop()
return nil
end
 
Line 119 ⟶ 126:
-- @return string describing the result
__call = function (self, func, ...)
-- resolve to the same level
local f1 = p.nop
local f2 = func
-- start the clock
local tick = os.clock()
local baseline = self.stats( self.runner(dummyf1, ...) )
-- a dummy function that is used for a baseline measure
local actual = self.stats( self.runner(funcf2, ...) )
function dummy()
return nil
end
local baseline = self.stats( self.runner(dummy, ...) )
local actual = self.stats( self.runner(func, ...) )
local combined = self.combine(baseline, actual)