import threading import time ind=2 def single(): for j in range(ind): for i in range(5000): print(i*2) def s(): for i in range(5000): print(i*2) def multi(): threa=[] for j in range(ind): threa.append(threading.Thread(target=s)) for t in threa: t.start() for t in threa: t.join() if __name__ == '__main__': start=time.time() single() end=time.time() sum=0 sum1=0 sum=end-start start=time.time() multi() end=time.time() sum1=end-start print('single',sum,'multi',sum1)
标签:__,end,python,threa,start,range,time,多线程,测速 From: https://www.cnblogs.com/hahaah/p/17368707.html