style(core.*, health.lua): better code style and backend strategy

This commit is contained in:
JuanZoran
2023-03-11 00:24:48 +08:00
parent 7fd7d1c309
commit 20fffe0ee5
12 changed files with 586 additions and 533 deletions

16
lua/Trans/util/init.lua Normal file
View File

@ -0,0 +1,16 @@
local M = {}
M.test_api_latency = function(urls)
urls = type(urls) == 'string' and { urls } or urls
local f = [[curl -s -o /dev/null -w '[%s]延迟: %%{time_total}s %s']]
local result = {}
for _, url in ipairs(urls) do
local cmd = string.format(f, url, url)
local res = vim.fn.system(cmd)
result[#result + 1] = res
end
vim.pretty_print(result)
end
return M