How to measure execution time of for loop in Python

1 Answer

0 votes
from time import process_time
  
start = process_time() 
   
result = 0;   
for i in range(10000):
    result = result + i

stop = process_time()
   
print(stop - start, "seconds")




'''
run:

0.0013729689999999982 seconds

'''

 



answered Mar 3, 2023 by avibootz
...