Table of contents
Solve the problem
AttributeError: module 'time' has no attribute 'clock'
Solutions
AttributeError: module 'time' has no attribute 'clock'
Solution
In Python 3.8 and later, time.clock()
the function has been removed . This function used to return processor time, which was not actual elapsed time, but CPU time used by the current process. Later, we can use time.perf_counter()
the function to get the current CPU time, or use time.process_time()
the function to get the CPU time used by the current process.
import time
start_time = time.perf_counter()
# some code to measure execution time
end_time = time.perf_counter()
print("Execution time:", end_time - start_time)
Will
time.clock()
changed to
time.perf_counter
You're done!