Chia sẻ code lua script đo tốc độ mạng || GameGuardian ||
1 minute read
Tốc độ mạng được đo như thế nào? Tốc độ mạng Internet được đo lường xác định bằng lượng kết nối tải xuống (tốc độ download) hay tải lên (tốc độ upload) trên mỗi giây. Trong hai trường hợp, tốc độ hiển thị ở dưới dạng bit trên giây (ký hiệu bps). Hôm nay tôi sẽ share cho ae 1 cách để đo tốc độ mạng bằng lua script chạy bằng GameGuardian hay nhé, Ae lưu ý giúp tôi là cái này chỉ là 1 ví dụ đơn giản để đo tốc độ mạng dựa trên thời gian của một file được tải xuống.
Measure_time = os.clock()
local file_doawnload = 10000000 -----dung lương tính = bytes
print("File size: " .. file_doawnload .. " bytes")
test_time_file = gg.makeRequest(' http://speedtest.ftp.otenet.gr/files/test1Mb.db ').content
pcall(load(test_time_file))
local file_size = #test_time_file
time_download= string.format("%.2f", (os.clock() - Measure_time) * 1000)
network_speed= ((1000000/time_download)*file_size)/1000
print(network_speed .." bytes/giây")
b=file_doawnload/network_speed
minutes = b / 60
minute=minutes*60
minute=b-minute
print("phút còn lại : "..minutes.." phút "..minute.." giây")
print("thời gian còn lại : "..b.." giây")
print("dung lượng file : "..file_doawnload.." bytes")
Đăng nhận xét