Skip to content

Instantly share code, notes, and snippets.

@est31
Last active August 29, 2015 14:15
Show Gist options
  • Save est31/e477d9a624dced5cb274 to your computer and use it in GitHub Desktop.
Save est31/e477d9a624dced5cb274 to your computer and use it in GitHub Desktop.
crafting speed test
-- file maintained at https://gist.github.com/est31/e477d9a624dced5cb274
-- tests basic crafting speed
local function crafting_loop()
local x = minetest.get_us_time()
local cnt = 20000
local locnt = 50
while cnt ~= 20000-locnt do
minetest.get_craft_result({
input = "normal",
items = {"test:whatever"..cnt+1},
})
cnt = cnt - 1
end
local y = minetest.get_us_time()
print('us time spent looking up: '..(y-x))
print('ms spent per craft lookup: '..(y-x)/(locnt*1000))
end
local x = minetest.get_us_time()
local cnt = 20000
--simulate a heavily modded game like dreambuilder
print('filling up the craft table...')
while cnt ~= 0 do
minetest.register_craft({
output = "test:whatever"..cnt,
recipe = {
{"test:whatever"..cnt+1},
}
})
cnt = cnt - 1
end
local y = minetest.get_us_time()
print('time spent registering: '..(y-x))
print('starting the crafting loop... ')
crafting_loop()
minetest.after(0.05, function()
print('starting the crafting loop... ')
crafting_loop()
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment