-1
Good evening, what could I do to know the time of each iteration that my code makes? Searching a little I found the command time.time(), but when the use in my code I get only 0.0 results. Someone could help me?
Follow the implementation of my code:
x_values = []
def eq_diff3(V):
return -V/10
values_dt = [0.01,0.1,1,2,10]
T = 50
for dt in values_dt:
start = time.time() #Começa contando aqui
V0 = 50
t = np.linspace(0,T,int(T/dt)+1)
x = np.zeros(len(t))
x[0] = V0
for i in range(1,len(t)):
start = time.time()
x[i] = x[i-1] + eq_diff3(x[i-1])*dt
vm_all.append(x)
x_values.append(t)
end = time.time() # termina de contar aqui
duration = end - start
print(duration) #printa quanto tempo demorou
Exit:
0.0
0.0
0.0
0.0
0.0
Try to be really small: https://ideone.com/vCU99h. Check what are the values of
start
andend
individually.– Woss
Thank you, I modified the code to first print the star value and then the end value as you suggested. I got the following for the first loop: start value is: 1599744343.5452778 end value is: 400.4330963 What this means?
– user158657
The website you sent me is telling me the time of each loop?
– user158657