If you want to have all the previous values for elapsedtime
use the below code. elapsed_list
holds these values for you.
import timeit
def copytest():
lst = []
for i in range(1000000):
lst.append(i)
starttime = timeit.default_timer()
copiedlst = lst.copy()
endtime = timeit.default_timer()
elapsedtime = endtime - starttime
elapsedtime += elapsedtime
return elapsedtime
elapsed_list = []
for j in range(1, 100):
e = copytest()
elapsed_list.append(e)
print(j, copytest())
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…