ahxcjxzxh 发表于 2018-8-8 13:52:25

Python 压力测试脚本

import urllib  

  
import threading
  
from time import ctime,sleep
  

  

  

  
def t1(func):
  
for i in range(10):
  
    f=urllib.urlopen("http://www.mystation.com/myinterface.html?param=value")
  
    s=f.read()
  
    print "round:%s, tread number:%s, returnValue:%s,time:%s" % (i, func, s, ctime())
  
    sleep(1)
  

  

  
if __name__ == '__main__':
  
threads=[]
  
for i in range(100):
  
    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()
页: [1]
查看完整版本: Python 压力测试脚本