我注意到加载此文件
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
哪一部分要花很长时间才能加载文件?
它在文件中说:
-- loading this file (takes a while but grants a boost of factor 13)
local PRELOAD_CACHE = true
将其设置为false,它将加载得更快,但运行速度会更慢。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句