fix 'timeit' in headless mode

This commit is contained in:
MihailRis 2024-12-11 14:08:24 +03:00
parent c67f158e62
commit b05c2fc911
4 changed files with 5 additions and 4 deletions

View File

@ -1,6 +1,7 @@
test.new_world("demo", "2019", "core:default")
assert(world.is_open())
assert(world.get_generator() == "core:default")
coroutine.yield()
test.sleep(1)
assert(world.get_total_time() > 0.0)
print(world.get_total_time())
test.close_world(true)

View File

@ -15,6 +15,7 @@ if test then
test.new_world = core.new_world
test.close_world = core.close_world
test.reconfig_packs = core.reconfig_packs
test.tick = coroutine.yield
end
------------------------------------------------

View File

@ -34,11 +34,11 @@ end
function timeit(iters, func, ...)
local tm = time.uptime()
local tm = os.clock()
for i=1,iters do
func(...)
end
print("[time mcs]", (time.uptime()-tm) * 1000000)
print("[time mcs]", (os.clock()-tm) * 1000000)
end
----------------------------------------------

View File

@ -1,5 +1,4 @@
#include "engine.hpp"
#include "window/Window.hpp"
#include "api_lua.hpp"
using namespace scripting;