benchmark
This commit is contained in:
parent
2f7bcd6eb1
commit
5b820547c4
@ -14,6 +14,9 @@ building_lib.register_building("building_lib:dummy_v2", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
mtt.register("build", function(callback)
|
mtt.register("build", function(callback)
|
||||||
|
-- clear store
|
||||||
|
building_lib.store:clear()
|
||||||
|
|
||||||
local mapblock_pos = {x=0, y=0, z=0}
|
local mapblock_pos = {x=0, y=0, z=0}
|
||||||
local building_name = "building_lib:dummy"
|
local building_name = "building_lib:dummy"
|
||||||
local rotation = 0
|
local rotation = 0
|
||||||
@ -75,5 +78,33 @@ mtt.register("build", function(callback)
|
|||||||
info = building_lib.get_placed_building_info(mapblock_pos)
|
info = building_lib.get_placed_building_info(mapblock_pos)
|
||||||
assert(info == nil)
|
assert(info == nil)
|
||||||
|
|
||||||
|
callback()
|
||||||
|
end)
|
||||||
|
|
||||||
|
mtt.benchmark("build", function(callback, iterations)
|
||||||
|
-- clear store
|
||||||
|
building_lib.store:clear()
|
||||||
|
|
||||||
|
local mapblock_pos = {x=0, y=0, z=0}
|
||||||
|
local building_name = "building_lib:dummy"
|
||||||
|
local rotation = 0
|
||||||
|
local playername = "singleplayer"
|
||||||
|
|
||||||
|
for _=1,iterations do
|
||||||
|
-- build
|
||||||
|
local callback_called = false
|
||||||
|
local success, err = building_lib.build(mapblock_pos, playername, building_name, rotation,
|
||||||
|
function() callback_called = true end
|
||||||
|
)
|
||||||
|
assert(not err)
|
||||||
|
assert(success)
|
||||||
|
assert(callback_called)
|
||||||
|
|
||||||
|
-- remove
|
||||||
|
success, err = building_lib.remove(mapblock_pos)
|
||||||
|
assert(not err)
|
||||||
|
assert(success)
|
||||||
|
end
|
||||||
|
|
||||||
callback()
|
callback()
|
||||||
end)
|
end)
|
@ -1,5 +1,6 @@
|
|||||||
default_game = minetest_game
|
default_game = minetest_game
|
||||||
mg_name = v7
|
mg_name = v7
|
||||||
mtt_enable = true
|
mtt_enable = true
|
||||||
|
mtt_enable_benchmarks = true
|
||||||
mtt_filter = building_lib
|
mtt_filter = building_lib
|
||||||
building_lib.enable_example_buildings = true
|
building_lib.enable_example_buildings = true
|
Loading…
x
Reference in New Issue
Block a user