[root@localhost zl]# vim ./test_luajit_perf.lua
[root@localhost zl]# time ./test_luajit_perf.lua
10000001
real 0m0.019s
user 0m0.017s
sys 0m0.001s
[root@localhost zl]#
[root@localhost zl]#
[root@localhost zl]# time ./test_lua_perf.lua
10000001
real 0m0.175s
user 0m0.174s
sys 0m0.001s
[root@localhost zl]# more test_luajit_perf.lua
#!/usr/local/bin/luajit
local i = 0
while 1 do
i = i+1
if i > 10000000 then
print(i)
break
end
end
[root@localhost zl]#
[root@localhost zl]# more test_lua_perf.lua
#!/usr/bin/lua
local i = 0
while 1 do
i = i+1
if i > 10000000 then
print(i)
break
end
end
[root@localhost zl]#
标准lua和luajit的一个代码测试对比
于 2023-10-10 15:35:20 首次发布
文章对比了使用LuaJIT和标准Lua编写的脚本在执行相同任务时的性能差异,LuaJIT显著优于纯Lua,显示出其在效率上的优势。
1219

被折叠的 条评论
为什么被折叠?



