Documentation for this module may be created at Module:Sandbox/RexxS/test/doc
local p = {}
--[[
Comparative testing of how fast we can access values.
empty = 0.00282
read a constant = 0.00274
100,000 empty loops = 0.00284
1,000,000 assign loops = 0.01328
10,000,000 assign loops = 0.0805
10,000,000 assign a numeric constant = 0.08234
10,000,000 assign a string constant = 0.08128
10,000,000 assign a variable = 0.0791
10,000,000 assign a table value, constant as index = 0.1456
10,000,000 assign a table value, variable as index = 0.16808
use:
{{#invoke:Sandbox/RexxS/test |speed |1e7}}
--]]
p.speed = function(frame)
local loops = tonumber(frame.args[1]) or 0
local x, y
y = 1
local args = {}
args[1] = 99
for i=1, loops do
x = args.y
end
return os.clock()
end
--[[
Checking resolution of os.time() - current time
It's 1 second
--]]
p.ostime = function(frame)
return os.time()
end
--[[
Checking resolution of os.clock() - time taken to run program
It's in 100 microseconds
--]]
p.osclock = function(frame)
return os.clock()
end
return p