rajinikanth rajinikanth - 1 year ago 49
Python Question

Total time for executing the code--python

I want to calculate the total time taken to execute the code and I want to stop executing code for some time.Is it possible?.If so anyone help me out how to approach this problem.


To get execution time in python Simple way is :

import time
start_time = time.time()
print("--- %s seconds ---" % (time.time() - start_time))

This assumes that your program takes at least a tenth of second to run.

Prints :

--- 0.764891862869 seconds ---

For stopping Execution for a while you can Use:

import time

This will wait for 6 second before executing next line of code