C Lua打印性能,Windows与Linux
使用C,具有C Lua打印性能,Windows与Linux,c,gcc,lua,mingw-w64,lua-5.3,C,Gcc,Lua,Mingw W64,Lua 5.3,使用C,具有 typedef struct Entity { size_t id; char *luaFun; } Entity; 和呼唤 void LuaEntityUpdate(Entity *entity, double dt) { lua_getglobal(L, entity->luaFun); lua_pushinteger(L, entity->id); lua_pushnumber(L, dt); lua_call(L
typedef struct Entity {
size_t id;
char *luaFun;
} Entity;
和呼唤
void LuaEntityUpdate(Entity *entity, double dt) {
lua_getglobal(L, entity->luaFun);
lua_pushinteger(L, entity->id);
lua_pushnumber(L, dt);
lua_call(L, 2, 0);
}
到全局(实体->luaFun=“实体\更新”)
循环中(单个游戏帧)大约需要:
- 使用Windows的128实体0.2秒*
- 对于使用Linux的8096实体,0.2秒**
local w = print
w(...)
-
-
但它们的表现都是一样的
我还尝试从Windows命令运行该程序,该命令比CLion中捕获的控制台快约30%
在Windows上有什么技巧可以加快速度吗?在lua部件中提供日志记录实用程序会很好,但即使对于调试,这对于实时应用程序来说也太慢了
另外:更改的标题可能是打印。。。如果不使用Lua进行输出,如何?请尝试测量k=1的
性能,1e4在Windows和Linux上打印“Hello World”end
。可能是打印。。。如果您不使用Lua进行输出,如何?请尝试测量k=1的性能,1e4在Windows和Linux上打印“Hello World”end
。
local w = print
w(...)
io.write(...)
local w = io.write
w(...)