local str = "hello,world,o ojid, jiadej,,, jidjie, jiajd, jiejd ,,jjie"
local str = string.rep(str, 100)
local res
for i = 1, 100000, 1 do
res = str_split(str, ",")
end
如果是之前的str_splite,结果:
time lua test.lua
real 0m40.556s
user 0m40.285s
sys 0m0.004s
替换后:
time lua test.lua
real 0m24.232s
user 0m24.067s
sys 0m0.003s
hello 对比了下之前str_splite和现在的str_splite的性能:
如果是之前的str_splite,结果: time lua test.lua real 0m40.556s
user 0m40.285s
sys 0m0.004s
替换后: time lua test.lua real 0m24.232s user 0m24.067s sys 0m0.003s
差距还是挺大的,gmatch性能更好。