我注意到加载此文件
https://raw.githubusercontent.com/kikito/sha1.lua/f607d523c133c08ab8e35cc6507e81273bb80053/sha1.lua
非常慢(使用Lua 5.1)。
#!/opt/homebrew/bin/lua
require("sha1")
print("Hello")
运行此命令:
$ time ./test.lua
Hello
real 0m0.774s
user 0m0.760s
sys 0m0.012s
删除require()
行后,它会大幅下降:
$ time ./test.lua
Hello
real 0m0.006s
user 0m0.002s
sys 0m0.003s
要加载文件需要这么长时间?
答案 0 :(得分:4)
它在文件中说:
-- loading this file (takes a while but grants a boost of factor 13)
local PRELOAD_CACHE = true
将其设置为false,它将加载更快但运行速度更慢。