day10_多线程性能测试

import threading,time,requests
run_times = []
def blog():
start_time = time.time()
r = requests.get('http://www.nnzhp.cn').text # 测试场景
end_time = time.time()
run_time = end_time - start_time
run_times.append(run_time)
objs = []
for i in range(100): # 并发数
t = threading.Thread(target = blog)
objs.append(t)
t.start()
for obj in objs:
# print(obj)
obj.join()
avg = sum(run_times)/len(run_times) # 平均响应时间
print(avg)
posted @ 2018-03-18 21:34  laosun0204  阅读(75)  评论(0编辑  收藏  举报