performance test again
This commit is contained in:
parent
7ca91020e3
commit
c5049d0e24
@ -8,8 +8,11 @@ assert(player.get_name(pid) == "Xerxes")
|
|||||||
test.sleep_until(function() return world.count_chunks() >= 9 end, 1000)
|
test.sleep_until(function() return world.count_chunks() >= 9 end, 1000)
|
||||||
print(world.count_chunks())
|
print(world.count_chunks())
|
||||||
|
|
||||||
timeit(10000000, block.get, 0, 0, 0)
|
for i=1,10 do
|
||||||
timeit(10000000, core.blank, 0, 0, 0)
|
print("--------------------")
|
||||||
|
timeit(10000000, block.get_fast, 0, 0, 0)
|
||||||
|
timeit(10000000, block.get, 0, 0, 0)
|
||||||
|
end
|
||||||
|
|
||||||
block.destruct(0, 0, 0, pid)
|
block.destruct(0, 0, 0, pid)
|
||||||
assert(block.get(0, 0, 0) == 0)
|
assert(block.get(0, 0, 0) == 0)
|
||||||
|
|||||||
@ -120,6 +120,15 @@ static int l_get(lua::State* L) {
|
|||||||
return lua::pushinteger(L, id);
|
return lua::pushinteger(L, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int l_get_fast(lua::State* L) {
|
||||||
|
auto x = lua::tointeger(L, 1);
|
||||||
|
auto y = lua::tointeger(L, 2);
|
||||||
|
auto z = lua::tointeger(L, 3);
|
||||||
|
auto vox = blocks_agent::get(*level->chunks, x, y, z);
|
||||||
|
int id = vox == nullptr ? -1 : vox->id;
|
||||||
|
return lua::pushinteger(L, id);
|
||||||
|
}
|
||||||
|
|
||||||
static int l_get_x(lua::State* L) {
|
static int l_get_x(lua::State* L) {
|
||||||
auto x = lua::tointeger(L, 1);
|
auto x = lua::tointeger(L, 1);
|
||||||
auto y = lua::tointeger(L, 2);
|
auto y = lua::tointeger(L, 2);
|
||||||
@ -629,6 +638,7 @@ const luaL_Reg blocklib[] = {
|
|||||||
{"is_solid_at", lua::wrap<l_is_solid_at>},
|
{"is_solid_at", lua::wrap<l_is_solid_at>},
|
||||||
{"is_replaceable_at", lua::wrap<l_is_replaceable_at>},
|
{"is_replaceable_at", lua::wrap<l_is_replaceable_at>},
|
||||||
{"set", lua::wrap<l_set>},
|
{"set", lua::wrap<l_set>},
|
||||||
|
{"get_fast", lua::wrap<l_get_fast>},
|
||||||
{"get", lua::wrap<l_get>},
|
{"get", lua::wrap<l_get>},
|
||||||
{"get_X", lua::wrap<l_get_x>},
|
{"get_X", lua::wrap<l_get_x>},
|
||||||
{"get_Y", lua::wrap<l_get_y>},
|
{"get_Y", lua::wrap<l_get_y>},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user