Which is more accurate to use, time.clock()
or time.time()
when time is measured in python?
For example,
#1. time.clock()
start = time.clock()
#Something code
elapsed = (time.clock() - start)
#2. time.time()
start = time.time()
#Something code
elapsed = (time.time() - start)
Which is the better way out of these two?
What is the difference between printing in python 2.7 and printing in Python?
python time accuracy
Officially, starting from Python 3.3, instead of time.clock()
time.process_time()
or time.It is recommended that you write perf_counter()
.
In the time module documentation in 2.7:
Unix returns the time of the current processor to floating point in seconds. "Processor time" and precision are the same as those in C.
Windows returns wall-clock
to floating point in seconds how long has passed since the first call was made.
The returned value is based on Wind32's QueryPerformanceCounter()
.
© 2024 OneMinuteCode. All rights reserved.