最近都在说网络不好,就是用 udp ping DO 的VPS 试试。昨天测试丢包还很少,今天测试出现了短暂的连续丢包。
但是单线程死循环发包到路由器查看速度只有 30Mbps/8 = 3.75MB/s 左右,高的时候35Mbps,低的时候25Mbps,python 线程单核近乎占满了,正常吗?
停掉了接收,完全只发送,速度能听达到50Mbps,看样瓶颈是cpu。
python 这个性能正常吗?
附:我这里是山东电信,单线程下载 DO ,刚开始速度100KB-200KB左右,有时能慢慢提升到2M。
def send_loop(sock,count):
for i in range(count):
try:
t = int(time.time()*1000)
data_t = struct.pack('!qq',t,i)
data = data_t + '0'*(SIZE - len(data_t))
s.sendto(data, address)
except:
logging.exception('send_loop')