2008-03-26
测试python rpc的性能
客户端:
import xmlrpclib,time
server = xmlrpclib.ServerProxy("http://localhost:8888")
for i in range(1,10):
a = time.time()
month = server.getMonth( 2002, i )
month = server.getMonth( 2002, i )
month = server.getMonth( 2002, i )
month = server.getMonth( 2002, i )
month = server.getMonth( 2002, i )
month = server.getMonth( 2002, i )
month = server.getMonth( 2002, i )
month = server.getMonth( 2002, i )
month = server.getMonth( 2002, i )
month = server.getMonth( 2002, i )
b = time.time()
print b-a
print month
服务器:
import calendar, SimpleXMLRPCServer
#The server object
class Calendar:
def getMonth(self, year, month):
return calendar.month(year, month)
def getYear(self, year):
return calendar.calendar(year)
calendar_object = Calendar()
server = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 8888))
server.register_instance(calendar_object)
#Go into the main listener loop
print "Listening on port 8888"
server.serve_forever()
结果:
0.077999830246
0.0310001373291
0.0469999313354
0.0310001373291
0.0469999313354
0.0309998989105
0.047000169754
0.0469999313354
0.0309998989105
基本上,每次请求的时间是0.03-0.04s
import xmlrpclib,time
server = xmlrpclib.ServerProxy("http://localhost:8888")
for i in range(1,10):
a = time.time()
month = server.getMonth( 2002, i )
month = server.getMonth( 2002, i )
month = server.getMonth( 2002, i )
month = server.getMonth( 2002, i )
month = server.getMonth( 2002, i )
month = server.getMonth( 2002, i )
month = server.getMonth( 2002, i )
month = server.getMonth( 2002, i )
month = server.getMonth( 2002, i )
month = server.getMonth( 2002, i )
b = time.time()
print b-a
print month
服务器:
import calendar, SimpleXMLRPCServer
#The server object
class Calendar:
def getMonth(self, year, month):
return calendar.month(year, month)
def getYear(self, year):
return calendar.calendar(year)
calendar_object = Calendar()
server = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 8888))
server.register_instance(calendar_object)
#Go into the main listener loop
print "Listening on port 8888"
server.serve_forever()
结果:
0.077999830246
0.0310001373291
0.0469999313354
0.0310001373291
0.0469999313354
0.0309998989105
0.047000169754
0.0469999313354
0.0309998989105
基本上,每次请求的时间是0.03-0.04s
发表评论
- 浏览: 5204 次
- 性别:

- 来自: 北京

- 详细资料
搜索本博客
最近加入圈子
最新评论
-
jboss rules brms和ruleAg ...
楼主能把完整的文档贴出来吗
-- by dong_ta -
jboss rules brms和ruleAg ...
我用代理怎么老是出现这种错误啊!麻烦给指点一下哈!我的版本一致. RuleAge ...
-- by chunchun_1010 -
jboss rules brms和ruleAg ...
我在创建新的Rule时,在"Add a condition to the rul ...
-- by myim -
我的第一个Ajax Wicket ...
个人感觉javaeye的圈子似乎有些冷清。我觉得可能跟javaeye即有圈子,又 ...
-- by tailorcai -
我的第一个Ajax Wicket ...
为啥不加入wicket的圈子,然后把这两篇文章放到圈子博客里呢
-- by fakechris






评论排行榜