Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C Lua打印性能,Windows与Linux_C_Gcc_Lua_Mingw W64_Lua 5.3 - Fatal编程技术网

C Lua打印性能,Windows与Linux

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

使用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, 2, 0);
}
到全局(实体->luaFun=“实体\更新”)

循环中(单个游戏帧)大约需要:

  • 使用Windows的128实体0.2秒*
  • 对于使用Linux的8096实体,0.2秒**
使Windows的构建速度大约比Linux慢64倍(同一台机器,运行的应用程序减少到最低限度,两者都使用100%的单核)

造成如此巨大差异的原因可能是什么?请参阅下面的评论和编辑

*Windows 10,Mingw-w64,来自“Mingw-w64-builds”,使用Lua5.3.5二进制版本

**造币厂16号,gcc,Lua5.3.5版本,官方来源

--编辑

正如我在评论中所建议的那样,我试图在不打印任何消息和宾果游戏的情况下测量性能!没有任何类型的打印,性能几乎与Linux版本相匹配

现在,我已尝试将打印替换为:

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(...)