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)
|
||||
-- clear store
|
||||
building_lib.store:clear()
|
||||
|
||||
local mapblock_pos = {x=0, y=0, z=0}
|
||||
local building_name = "building_lib:dummy"
|
||||
local rotation = 0
|
||||
@ -77,3 +80,31 @@ mtt.register("build", function(callback)
|
||||
|
||||
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()
|
||||
end)
|
@ -1,5 +1,6 @@
|
||||
default_game = minetest_game
|
||||
mg_name = v7
|
||||
mtt_enable = true
|
||||
mtt_enable_benchmarks = true
|
||||
mtt_filter = building_lib
|
||||
building_lib.enable_example_buildings = true
|
Loading…
x
Reference in New Issue
Block a user