发布时间:2019-08-29 07:42:47编辑:auto阅读(1697)
目前只针对Http Get进行模拟
import urllib
import datetime
import threading
from time import ctime,sleep
def t1(func):
for i in range(50):
starttime = datetime.datetime.now()
url = "http://localhost:8080/api/test?pid=10000&mobile=%s%03d%02d&type=abc" % ('135000', func, i)
f=urllib.urlopen(url)
s=f.read()
endtime = datetime.datetime.now()
print "round:%s, tread number:%s, returnValue:%s,time:%f" % (i, func, s, (endtime - starttime).microseconds / 1000)
sleep(1)
if __name__ == '__main__':
threads=[]
for i in range(50):
name = "t%s" % (i)
name = threading.Thread(target=t1,args=(i,))
threads.append(name)
for t in threads:
t.setDaemon(True)
t.start()
t.join()
上一篇: 003_001 Python 计算昨天和
下一篇: Windows下面制作绿色版的Pytho
47623
46025
36925
34495
29102
25754
24589
19731
19276
17772
5585°
6170°
5710°
5766°
6721°
5501°
5507°
6008°
5978°
7309°