Last active
May 7, 2016 05:44
-
-
Save HybridDog/e8b6e64303671edbe734 to your computer and use it in GitHub Desktop.
how often those functions get executed in three seconds
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 os_clock = minetest.get_us_time | |
local TIME = 3*1000000 | |
local function time_sth(fct, ...) | |
local start = os_clock() | |
local fin = start | |
local total = 0 | |
while fin-start < TIME do | |
fct(...) | |
total = total + 1 | |
fin = os_clock() | |
end | |
return total | |
end | |
minetest.register_node("ac:nodepar2speed", { | |
description = "npar2speed", | |
tiles = {"ac_block.png"}, | |
groups = {snappy=1,bendy=2,cracky=1}, | |
sounds = default.node_sound_stone_defaults(), | |
after_place_node = function(pos) | |
print(time_sth(function(pos) | |
local node = minetest.get_node(pos) | |
node.param2 = 1 | |
minetest.set_node(pos, node) | |
end, pos)) | |
print(time_sth(function(pos) | |
minetest.get_meta(pos):set_string("nodecay", "true") | |
end, pos)) | |
print(time_sth(function(pos) | |
local decay = minetest.get_node(pos).param2 == 1 | |
end, pos)) | |
print(time_sth(function(pos) | |
local decay = minetest.get_meta(pos):get_string("nodecay") == "true" | |
end, pos)) | |
end, | |
}) | |
--[[ | |
results: | |
361345 | |
1624376 | |
2590331 | |
1805276 | |
367324 | |
1716379 | |
2719357 | |
1846280 | |
297543 | |
1444709 | |
2156300 | |
1621505 | |
]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
see minetest/minetest_game#947 (comment)