Posted 02 May 2015 - 12:39 AM
This may be a silly question to ask, but how much CPU does os.pullEvent take up? I understand that it's really just a matter of coroutine.yield. However, are there other considerations, like the computer yielding excessively, taking up time? If there were 3 events in the event stack, key, rednet_message, and timer, and they all triggered a certain function, how much longer would this take to perform than if the functions were just executed right then and there? For example…
as opposed to:
The reason I ask is because each time I have many timer events it seems to bog down the performance, even if there's very little execution they do when it's triggered.
function keyPress()
print("a key event was just triggered!")
end
function rednetMessage()
print("a rednet message event was just triggered!")
end
function timer()
print("a timer event was just triggered!")
end
while true do
local event = os.pullEvent() -- 3 events initially in stack; will yield three times
if event == "key" then keyPress()
elseif event == "rednet_message" then rednetMessage()
elseif event == "timer" then timer() end
end
as opposed to:
keyPress()
rednetMessage()
timer()
The reason I ask is because each time I have many timer events it seems to bog down the performance, even if there's very little execution they do when it's triggered.