style(core.*, health.lua): better code style and backend strategy
This commit is contained in:
		
							
								
								
									
										16
									
								
								lua/Trans/util/init.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								lua/Trans/util/init.lua
									
									
									
									
									
										Normal 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
 | 
			
		||||
		Reference in New Issue
	
	Block a user