Search code examples
pythontimesubtractionexecute

Script execution time for import time --> What units are the results in?


I'm using import time module to calculate how long each run of my while loop took to execute.

The code is below:

while (...):
   start = time.time()

   ...code here

   end = time.time()
   
   print (f"python loop execution total time {end-start}")

The code above returns me: "python loop execution total time 2.3876123428344727"

Is this 2.3876123428344727 value in seconds or milliseconds or something else? I guess what I am asking is what unit of time the code returns.


Solution

  • From the documentation:

    Return the time in seconds since the epoch as a floating point number.