Last active
August 29, 2015 14:15
-
-
Save est31/e477d9a624dced5cb274 to your computer and use it in GitHub Desktop.
crafting speed test
This file contains hidden or 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
-- 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