python - Computing Time on Each Iteration -


i trying compute time every loop iterations. however, have noticed time required process (anything) increases on each iteration in incremental fashion. computing time using following commands:

start_time = time.time() loop:      (any process) print (time.time() - start_time)) 

when call time.time method returning amount of time in seconds based on unix clock system, time local system.

you assigning time start_time, running 10 processes , outputting current time minus start_time, working out how long takes run 10 processes.

now believe you're trying calculate how long each individual process takes, need move around of lines in sample code supplied:

    import time         in range(10):          start_time = time.time()             (any process)          print(time.time() - start_time)) 

by moving assignment of time loop assigning time @ loop starts , outputting individual time of each iteration rather timing how long entire loop takes whole.

this output how long each iteration takes.

please feel free ask questions!


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -