不同版本的收發效率
名詞解釋:CHARGEN是在TCP連接建立後,服務器不斷傳送任意的字符到客戶端,直到客戶端關閉連接。
客戶端:
recipes/tpc/netcat.cc. 每個線程一個連接
recipes/python/netcat.py io複用
recipes/python/netcat-nonblockpy io複用
服務端:
recipes/tpc/chargen.cc
recipes/python/chargen.py
recipes/examples/simple/chargen/*
測試指令:
1.客戶端 nc localhost 1234 > /dev/null
注意:#/dev/null是指獲取服務器上的數據不打印出來,丟掉
2. 服務端 ./chargen -l 1234
3. 打開終端,輸入top查看cpu使用
測試如圖:
chargen in c++ | chargen in python | chargen in muduo | |
---|---|---|---|
nc | 1600 | ||
netcat.cc | 2800 | ||
nectar.py | 1000 | ||
netcat_nonblock | 1000 |