I am trying to see how fast my code runs, but this operation that takes the 60FPS average is slowing down the actual reading, which is ridiculous for what it does.
function engine:draw(t,RPM)
local b4=tick() -- store before ran
--code we are checking the run time of:
Piston:Update(t)
Piston2:Update(t)
Piston3:Update(t)
Piston4:Update(t)
--sending out the average to print:
table.insert(avg,1,tick()-b4 )
local sum = 0
if avg[11] then avg[11] = nil end -- keep it at 10?
for i,x in ipairs(avg) do
sum=sum+x
end
print("Average for the last " .. #avg .. " frames: " .. sum/#avg)
end