Good Evening,
I am trying to estimate the remaining time to the end of a loop; I've used:
start = datetime.now()
progress = 0
for i in range(1000):
#do a few calculations
progress += 1
stop = datetime.now()
execution_time = stop-start
remaining = execution_time * ( 1000 - progress )
print("Progress:", progress, "%, estimated", remaining, "time remaining")
But it does not seem to work properly, since it goes up to minutes, even though the loop would take 20 seconds in total, and decrease quickly when reaching the end.
How can I try to forecast the remaining time of a loop efficiently and correctly?
Simply use tqdm
package:
from tqdm import tqdm
for i in tqdm(range(10000)):
dosomthing()
It will print for you everything:
76%|█████████████ | 7568/10000 [00:33<00:10, 229.00it/s]
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments