Skip to content

Instantly share code, notes, and snippets.

@Desour
Created August 2, 2019 12:58
Show Gist options
  • Save Desour/acc13c4399fbd08b4ba8c50ea2596092 to your computer and use it in GitHub Desktop.
Save Desour/acc13c4399fbd08b4ba8c50ea2596092 to your computer and use it in GitHub Desktop.
minetest set_wielded_item speed test
local n = 1000
minetest.register_chatcommand("swi", {
params = "",
description = "",
privs = {},
func = function(name, param)
local player = minetest.get_player_by_name(name)
local item = player:get_wielded_item()
local time_start = minetest.get_us_time()
player:set_wielded_item(item)
local dt1 = minetest.get_us_time() - time_start
time_start = minetest.get_us_time()
for i = 1, n do
player:set_wielded_item(item)
end
local dtn = minetest.get_us_time() - time_start
return true, "dt1: " .. dt1 .. ", dtn: " .. dtn / n
end,
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment