球爱酒吧祁丹兔女郎:[twisted] tcp 与 domain socket 性能对比
来源:百度文库 编辑:偶看新闻 时间:2024/05/02 09:50:05
[twisted] tcp 与 domain socket 性能对比
2010-07-06 16:31:26| 分类:net_Twisted| 标签:|字号大中小 订阅
在 twisted 基础上,测试了下 tcp 与 unix domain socket 的性能对比。扣除 python/twisted 本身的消耗,下面的数据还是能一定的参考意义的。测试结果在3台机器上跑了测试,比较诡异的是,有一台机器的 tcp 速度既然有点慢,哈。128 bytes / line 1024*8 lines 一共 1Mb 数据
CPU: Intel(R) Xeon(R) CPU 5130 @ 2.00GHz (1995.01-MHz 686-class CPU)real memory = 3488677888 (3327 MB)TCP 需要 0.230 sDomain Socket 需要 0.064 s
CPU: Intel(R) Xeon(R) CPU 5130 @ 2.00GHz (1995.01-MHz 686-class CPU)real memory = 3488677888 (3327 MB)TCP 需要 0.133 sDomain Socket 需要 0.064 s
CPU: Intel(R) Xeon(R) CPU E5405 @ 2.00GHz (1995.01-MHz 686-class CPU)real memory = 3220992000 (3071 MB)TCP 需要 0.130 sDomain Socket 需要 0.062 s
测试程序----------------------------- tcpsvr.py --------------------------------# vim: tabstop=4 expandtab :
import time, sysfrom twisted.internet.protocol import Factoryfrom twisted.protocols.basic import LineReceiverfrom twisted.internet import reactorfrom twisted.python import log
class MyTCPProto(LineReceiver): def lineReceived(self, line): if line == "profile_start": self.factory.start_time = time.time() log.msg("start: %f" % self.factory.start_time) elif line == "profile_end": end_time = time.time() log.msg("end: %f, delta: %f" % (end_time, end_time - self.factory.start_time))
# do nothing
class MyTCPFactory(Factory): protocol = MyTCPProto
log.startLogging(sys.stdout)
f = MyTCPFactory()reactor.listenTCP(2100, f, interface="127.0.0.1")# reactor.listenUNIX("/tmp/foobar", f)reactor.run()---------------------------- tcpcli.py ---------------------------------# vim: tabstop=4 expandtab :
from twisted.internet import reactor, protocol
class MyTCPProto(protocol.Protocol): def connectionMade(self): self.transport.write("profile_start\r\n") data = ("a"*128 + "\r\n") * 1024 * 8 self.transport.write(data) self.transport.write("profile_end\r\n")
class MyTCPFactory(protocol.ClientFactory): protocol = MyTCPProto
f = MyTCPFactory()reactor.connectTCP("127.0.0.1", 2100, f)# reactor.connectUNIX("/tmp/foobar", f)reactor.run()-------------------------------------------------------------------------
TCP与UDP区别
UDP与TCP区别?
tcp与udp的区别?
关于Twisted Tracks
microsoft tcp/ip与internet tcp/ip区别
microsoft tcp/ip与internet tcp/ip区别
twisted meadows在哪下载?
TCP与UDP有什么区别?
TCP与UDP有什么区别?
TCP 和UDP的概念与关系?
TCP协议与UDP协议的共同点
TCP协议与UDP协议的共同点
TCP端口与接口的区别
TCP与TAB的相关知识
TCP协议与UDP协议有什么相同与不同
ps1的问题。twisted metal。烈火战车
your mind is Tiffany-twisted?什么意思?
OSI与TCP/IP有什么不同
比较 ISO/RM与TCP/IP体系结构
TCP/IP协议与netbeui的异同?
ad hoc 与tcp/ip每层对应吗?
internet网与tcp/ip的问题
udp与tcp在网络通讯方面的区别
ppp协议与TCP/IP协议的关系