How to use time. time

I heard that for a few things i will need time.time and wantet to ask how that works cause i did not find an discusion abaut that

A common use of the time.time function is to measure the length of time something takes to process.

In the following script, we have a function that counts to some number. Prior to calling the function, we record the current time. After the function has completed its task, we again record the present time. We then take the difference to calculate the total elapsed time.

import time

def func():
    counter = 0

    for i in range(5000000):
        counter += 1
    print(f'Final value is: {counter}')

t1 = time.time()
func()
print(f'Time elapsed is: {(time.time() - t1)} s')