Created
January 8, 2017 11:33
-
-
Save HybridDog/aeba934739beb29dc3b41892a55ed283 to your computer and use it in GitHub Desktop.
on_chatmessage wraps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local t | |
minetest.register_on_chat_message(function() | |
t = minetest.get_us_time() | |
end) | |
for _ = 1,1000 do | |
minetest.register_on_chat_message(function() end) | |
end | |
minetest.register_on_chat_message(function() | |
print("direct: " .. minetest.get_us_time() - t .. " ms") | |
end) | |
local ocs = {} | |
local function ocw(func) | |
ocs[#ocs + 1] = func | |
end | |
minetest.register_on_chat_message(function() | |
t = minetest.get_us_time() | |
end) | |
minetest.register_on_chat_message(function(name, message) | |
for i = 1,#ocs do | |
if ocs[i](name, message) then | |
return | |
end | |
end | |
end) | |
for _ = 1,1000 do | |
ocw(function() end) | |
end | |
minetest.register_on_chat_message(function() | |
print("wrap: " .. minetest.get_us_time() - t .. " ms") | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
results
Note that ms should be µs there.