Module:Sandbox/Dessamator/Module:Performance

-- //Tests performance of a module local perftest = {}

function perftest.run(testfunc1,testfunc2) local cpuRunTime = {0,0} local elapsedTime2 = {0,0} nClock = os.clock testfunc1 cpuRunTime[1]= os.clock-nClock

nClock = os.clock testfunc2 cpuRunTime[2] = os.clock-nClock

mw.log("Run time function 1: " .. cpuRunTime[1]) mw.log("Run time function 2: " .. cpuRunTime[2]) return testTime end

local function test1 s = "the quick brown fox jumps over the lazy dog" w = "foo"

strPat = ".*" .. w   nClock = os.clock for i=1,99999 do s:find(strPat) end end

local function test2 s = "the quick brown fox jumps over the lazy dog" w = "foo" strPat = "^.*" .. w   nClock = os.clock for i = 1,99999 do s:find(strPat) end end

function perftest.run1 perftest.run(test1,test2) end return perftest