Home>Article>Backend Development> How to use the time module in Python to monitor program running time
Time.time and time.clock can be used in Python to calculate the program running time.
time.time method:
Returns the timestamp of the current time, calculating the time from the beginning of the program to the end of the program.
The code is as follows:
start = time.time() run_fun() end = time.time() print end-start
time.clock method:
Calculates the CPU time of program running
Code As follows:
start = time.clock() run_fun() end = time.clock() print end-start
For more Python-related technical articles, please visit thePython Tutorialcolumn to learn!
The above is the detailed content of How to use the time module in Python to monitor program running time. For more information, please follow other related articles on the PHP Chinese website!