upyun / slardar

Updating your upstream list and run lua scripts without reloading Nginx.
493 stars 111 forks source link

faster str_splite #15

Closed fankeke closed 7 years ago

fankeke commented 7 years ago

hello 对比了下之前str_splite和现在的str_splite的性能:

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

差距还是挺大的,gmatch性能更好。

huangnauh commented 7 years ago

LGTM